ThermoDb
A fork of minimongo for agnostic datasources.
Usage
; const db = ; const collection = await db;// collection === db.collections.things === db.things const foo = await collection;// -> { id: ..., a: 'Hello' }
API
HybridDb
Combines results from the local database with remote data.
; const db = localDb remoteDb; await db;
IndexedDb
Make a local database backed by IndexedDb:
; const db = /* Optionally define the key attribute of the documents. Will default to KeyUtil.getField() */ key: null /* Optionally define the KeyUtil instance to generate and manage document ids */ keyUtil: null /* Optionally define a namespace to store data */ namespace: 'default'; // all options override db optionsawait db;
MemoryDb
Make an in-memory local database backed by a simple JavaScript object.
; const db = /* Optionally define the key attribute of the documents. Will default to KeyUtil.getField() */ key: null /* Optionally define the KeyUtil instance to generate and manage document ids */ keyUtil: null /* Optionally define the strategy when returning documents: - "clone" (default) will deep clone the document before returning it - "freeze" will prevent any modification of the returned document */ safety: "clone"; // all options override db optionsawait db;
RemoteDb
Uses AJAX-JSON calls to an API to query a server-side database.
; const db = /* Optionally define the name of the client that will be passed as argument to the API */ client: null /* Optionally define the KeyUtil instance to generate and manage document ids */ keyUtil: null /* The API URL to request and post data */ url: '' /* Optionally define a function provding the implementation to send data to the API server */ httpClient: defaultHttpClient /* Optionally define the options to pass to the httpClient function */ httpOptions: null /* Does the API support QuickFind? */ useQuickFind: true /* Does the API support POST request? */ usePostFind: true; await db;
Database instances
await db;// -> a Collection instance await db;// -> undefined db;// -> Array<String>
Collection instances
dbcollections'foo' === db'foo';// -> true await dbfoo;// -> Array<Object> await dbfoo;// -> Object await dbfoo;// -> Object or Array<Object> await dbfoo;// -> mixed