I have looked at linvodb3 and pouchdb for a project that I am working on. According to https://stackoverflow.com/a/35142175, I cannot access a IndexDB database from CLI directly when created through angular-cli.
Is there a NoSQL database usable in NodeJS/Angular2 app that creates an instance reachable from the CLI and web page without using a server instance?
I need to pre-ship a database with information that will not be updated on the client (at least in the early stages) but allows searching and other database features for a offline document library.
Edit 1
let PouchDB = require('pouchdb');
let db = PouchDB('./db');
This gives me a folder named "db" which has the database files it when testing directly from NodeJS CLI. As, long as I call the same db folder from both Angular2 and NodeJS then I can pre-publish data.
For Angular2:
import * as PouchDB from 'pouchdb';
import { Injectable } from '@angular/core';
@Injectable()
export class PouchdbService {
private _db: any; // <-- Database Object
private _databaseName: string = "./my_db"; // <-- Database == folder location
constructor() {
this._db = new PouchDB(this._databaseName);
}
}
From NodeJS:
#!/usr/bin/env node
'use strict'
let PouchDB = require ('pouchdb');
let databaseName = "./my_db"; // <-- same as in angular
let db = new PouchDb ( databaseName ); // <-- should be the same database