flamusdiu flamusdiu - 8 months ago 112
Node.js Question

NodeJS + RxDB + Electron w/ persistent data

I have been playing around with PouchDB (using express-pouchdb and pouchdb-find) for a while and realized that I needed to work with some streams through Rxjs for my Angular 5/Electron app.

For my current setup, I run express-pouchdb to set up a localized PouchDB for persistence and then in Angular I have the following:

@Injectable()
export class PouchdbService {
private _localdb = 'http://localhost:3000/main';
private _pouchDb: any;

constructor() {
this._pouchDb = new PouchDB(this._localdb);
PouchDB.plugin(PouchDBFind);

this.createIndexes();
}

private createIndexes(): void {
this._pouchDb.createIndex({
index: {
fields: [ 'tags' ]
}
});

this._pouchDb.createIndex({
index: {
fields: [ 'date' ]
}
})

this._pouchDb.createIndex({
index: {
fields: [ 'title' ]
}
});
}


This provides my service to the express app through
_localdb
property. I could keep the
PouchDB
express app and just call it through RxDB by rewriting my service and refactoring the code. However, I guess that I need have to call sync on every collection.

Though, I would rather drop the express application if there was a way to run with persistence with RxDB directly.

Answer Source

I ended up using the websql adapter which apparently stores information between application loads and dropped express-pouchdb.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download