mirror of https://github.com/seald/nedb
parent
32cff9b921
commit
2ec0101d7b
@ -1,181 +0,0 @@ |
|||||||
<a name="Cursor"></a> |
|
||||||
|
|
||||||
## Cursor ⇐ <code>Promise</code> |
|
||||||
<p>Manage access to data, be it to find, update or remove it.</p> |
|
||||||
<p>It extends <code>Promise</code> so that its methods (which return <code>this</code>) are chainable & awaitable.</p> |
|
||||||
|
|
||||||
**Kind**: global class |
|
||||||
**Extends**: <code>Promise</code> |
|
||||||
|
|
||||||
* [Cursor](#Cursor) ⇐ <code>Promise</code> |
|
||||||
* [new Cursor(db, query, [execFn], [hasCallback])](#new_Cursor_new) |
|
||||||
* _instance_ |
|
||||||
* [.db](#Cursor+db) : [<code>Datastore</code>](#Datastore) |
|
||||||
* [.query](#Cursor+query) : [<code>query</code>](#query) |
|
||||||
* [.hasCallback](#Cursor+hasCallback) : <code>boolean</code> |
|
||||||
* [.limit(limit)](#Cursor+limit) ⇒ [<code>Cursor</code>](#Cursor) |
|
||||||
* [.skip(skip)](#Cursor+skip) ⇒ [<code>Cursor</code>](#Cursor) |
|
||||||
* [.sort(sortQuery)](#Cursor+sort) ⇒ [<code>Cursor</code>](#Cursor) |
|
||||||
* [.projection(projection)](#Cursor+projection) ⇒ [<code>Cursor</code>](#Cursor) |
|
||||||
* [.project(candidates)](#Cursor+project) ⇒ [<code>Array.<document></code>](#document) |
|
||||||
* [._execAsync()](#Cursor+_execAsync) ⇒ [<code>Array.<document></code>](#document) \| <code>Promise.<\*></code> |
|
||||||
* [._exec(_callback)](#Cursor+_exec) |
|
||||||
* [.exec(_callback)](#Cursor+exec) |
|
||||||
* [.execAsync()](#Cursor+execAsync) ⇒ <code>Promise.<(Array.<document>\|\*)></code> |
|
||||||
* _inner_ |
|
||||||
* [~execFnWithCallback](#Cursor..execFnWithCallback) : <code>function</code> |
|
||||||
* [~execFnWithoutCallback](#Cursor..execFnWithoutCallback) ⇒ <code>Promise</code> \| <code>\*</code> |
|
||||||
* [~execCallback](#Cursor..execCallback) : <code>function</code> |
|
||||||
|
|
||||||
<a name="new_Cursor_new"></a> |
|
||||||
|
|
||||||
### new Cursor(db, query, [execFn], [hasCallback]) |
|
||||||
<p>Create a new cursor for this collection</p> |
|
||||||
|
|
||||||
**Params** |
|
||||||
|
|
||||||
- db [<code>Datastore</code>](#Datastore) - <p>The datastore this cursor is bound to</p> |
|
||||||
- query [<code>query</code>](#query) - <p>The query this cursor will operate on</p> |
|
||||||
- [execFn] [<code>execFnWithoutCallback</code>](#Cursor..execFnWithoutCallback) | [<code>execFnWithCallback</code>](#Cursor..execFnWithCallback) - <p>Handler to be executed after cursor has found the results and before the callback passed to find/findOne/update/remove</p> |
|
||||||
- [hasCallback] <code>boolean</code> <code> = true</code> - <p>If false, specifies that the <code>execFn</code> is of type [execFnWithoutCallback](#Cursor..execFnWithoutCallback) rather than [execFnWithCallback](#Cursor..execFnWithCallback).</p> |
|
||||||
|
|
||||||
<a name="Cursor+db"></a> |
|
||||||
|
|
||||||
### cursor.db : [<code>Datastore</code>](#Datastore) |
|
||||||
**Kind**: instance property of [<code>Cursor</code>](#Cursor) |
|
||||||
**Access**: protected |
|
||||||
<a name="Cursor+query"></a> |
|
||||||
|
|
||||||
### cursor.query : [<code>query</code>](#query) |
|
||||||
**Kind**: instance property of [<code>Cursor</code>](#Cursor) |
|
||||||
**Access**: protected |
|
||||||
<a name="Cursor+hasCallback"></a> |
|
||||||
|
|
||||||
### cursor.hasCallback : <code>boolean</code> |
|
||||||
<p>Determines if the [Cursor#execFn](Cursor#execFn) is an [execFnWithoutCallback](#Cursor..execFnWithoutCallback) or not.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Cursor</code>](#Cursor) |
|
||||||
**Access**: protected |
|
||||||
<a name="Cursor+limit"></a> |
|
||||||
|
|
||||||
### cursor.limit(limit) ⇒ [<code>Cursor</code>](#Cursor) |
|
||||||
<p>Set a limit to the number of results</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Cursor</code>](#Cursor) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- limit <code>Number</code> |
|
||||||
|
|
||||||
<a name="Cursor+skip"></a> |
|
||||||
|
|
||||||
### cursor.skip(skip) ⇒ [<code>Cursor</code>](#Cursor) |
|
||||||
<p>Skip a number of results</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Cursor</code>](#Cursor) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- skip <code>Number</code> |
|
||||||
|
|
||||||
<a name="Cursor+sort"></a> |
|
||||||
|
|
||||||
### cursor.sort(sortQuery) ⇒ [<code>Cursor</code>](#Cursor) |
|
||||||
<p>Sort results of the query</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Cursor</code>](#Cursor) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- sortQuery <code>Object.<string, number></code> - <p>sortQuery is { field: order }, field can use the dot-notation, order is 1 for ascending and -1 for descending</p> |
|
||||||
|
|
||||||
<a name="Cursor+projection"></a> |
|
||||||
|
|
||||||
### cursor.projection(projection) ⇒ [<code>Cursor</code>](#Cursor) |
|
||||||
<p>Add the use of a projection</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Cursor</code>](#Cursor) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- projection <code>Object.<string, number></code> - <p>MongoDB-style projection. {} means take all fields. Then it's { key1: 1, key2: 1 } to take only key1 and key2 |
|
||||||
{ key1: 0, key2: 0 } to omit only key1 and key2. Except _id, you can't mix takes and omits.</p> |
|
||||||
|
|
||||||
<a name="Cursor+project"></a> |
|
||||||
|
|
||||||
### cursor.project(candidates) ⇒ [<code>Array.<document></code>](#document) |
|
||||||
<p>Apply the projection.</p> |
|
||||||
<p>This is an internal function. You should use [execAsync](#Cursor+execAsync) or [exec](#Cursor+exec).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Cursor</code>](#Cursor) |
|
||||||
**Access**: protected |
|
||||||
**Params** |
|
||||||
|
|
||||||
- candidates [<code>Array.<document></code>](#document) |
|
||||||
|
|
||||||
<a name="Cursor+_execAsync"></a> |
|
||||||
|
|
||||||
### cursor.\_execAsync() ⇒ [<code>Array.<document></code>](#document) \| <code>Promise.<\*></code> |
|
||||||
<p>Get all matching elements |
|
||||||
Will return pointers to matched elements (shallow copies), returning full copies is the role of find or findOne |
|
||||||
This is an internal function, use execAsync which uses the executor</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Cursor</code>](#Cursor) |
|
||||||
<a name="Cursor+_exec"></a> |
|
||||||
|
|
||||||
### cursor.\_exec(_callback) |
|
||||||
<p>Get all matching elements |
|
||||||
Will return pointers to matched elements (shallow copies), returning full copies is the role of find or findOne</p> |
|
||||||
<p>This is an internal function, use [exec](#Cursor+exec) which uses the [executor](#Datastore+executor).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Cursor</code>](#Cursor) |
|
||||||
**Access**: protected |
|
||||||
**See**: Cursor#exec |
|
||||||
**Params** |
|
||||||
|
|
||||||
- _callback [<code>execCallback</code>](#Cursor..execCallback) |
|
||||||
|
|
||||||
<a name="Cursor+exec"></a> |
|
||||||
|
|
||||||
### cursor.exec(_callback) |
|
||||||
<p>Get all matching elements |
|
||||||
Will return pointers to matched elements (shallow copies), returning full copies is the role of find or findOne</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Cursor</code>](#Cursor) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- _callback [<code>execCallback</code>](#Cursor..execCallback) |
|
||||||
|
|
||||||
<a name="Cursor+execAsync"></a> |
|
||||||
|
|
||||||
### cursor.execAsync() ⇒ <code>Promise.<(Array.<document>\|\*)></code> |
|
||||||
<p>Async version of [exec](#Cursor+exec).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Cursor</code>](#Cursor) |
|
||||||
**See**: Cursor#exec |
|
||||||
<a name="Cursor..execFnWithCallback"></a> |
|
||||||
|
|
||||||
### Cursor~execFnWithCallback : <code>function</code> |
|
||||||
<p>Has a callback</p> |
|
||||||
|
|
||||||
**Kind**: inner typedef of [<code>Cursor</code>](#Cursor) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- err <code>Error</code> |
|
||||||
- res [<code>?Array.<document></code>](#document) | [<code>document</code>](#document) |
|
||||||
|
|
||||||
<a name="Cursor..execFnWithoutCallback"></a> |
|
||||||
|
|
||||||
### Cursor~execFnWithoutCallback ⇒ <code>Promise</code> \| <code>\*</code> |
|
||||||
<p>Does not have a callback, may return a Promise.</p> |
|
||||||
|
|
||||||
**Kind**: inner typedef of [<code>Cursor</code>](#Cursor) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- res [<code>?Array.<document></code>](#document) | [<code>document</code>](#document) |
|
||||||
|
|
||||||
<a name="Cursor..execCallback"></a> |
|
||||||
|
|
||||||
### Cursor~execCallback : <code>function</code> |
|
||||||
**Kind**: inner typedef of [<code>Cursor</code>](#Cursor) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- err <code>Error</code> |
|
||||||
- res [<code>Array.<document></code>](#document) | <code>\*</code> - <p>If an execFn was given to the Cursor, then the type of this parameter is the one returned by the execFn.</p> |
|
||||||
|
|
@ -1,568 +0,0 @@ |
|||||||
<a name="Datastore"></a> |
|
||||||
|
|
||||||
## Datastore ⇐ <code>EventEmitter</code> |
|
||||||
<p>The <code>Datastore</code> class is the main class of NeDB.</p> |
|
||||||
|
|
||||||
**Kind**: global class |
|
||||||
**Extends**: <code>EventEmitter</code> |
|
||||||
**Emits**: <code>Datastore#event:"compaction.done"</code> |
|
||||||
|
|
||||||
* [Datastore](#Datastore) ⇐ <code>EventEmitter</code> |
|
||||||
* [new Datastore(options)](#new_Datastore_new) |
|
||||||
* _instance_ |
|
||||||
* [.inMemoryOnly](#Datastore+inMemoryOnly) : <code>boolean</code> |
|
||||||
* [.autoload](#Datastore+autoload) : <code>boolean</code> |
|
||||||
* [.timestampData](#Datastore+timestampData) : <code>boolean</code> |
|
||||||
* [.filename](#Datastore+filename) : <code>string</code> |
|
||||||
* [.persistence](#Datastore+persistence) : [<code>Persistence</code>](#Persistence) |
|
||||||
* [.executor](#Datastore+executor) : [<code>Executor</code>](#Executor) |
|
||||||
* [.indexes](#Datastore+indexes) : <code>Object.<string, Index></code> |
|
||||||
* [.ttlIndexes](#Datastore+ttlIndexes) : <code>Object.<string, number></code> |
|
||||||
* [.autoloadPromise](#Datastore+autoloadPromise) : <code>Promise</code> |
|
||||||
* [.compareStrings()](#Datastore+compareStrings) : [<code>compareStrings</code>](#compareStrings) |
|
||||||
* [.loadDatabase(callback)](#Datastore+loadDatabase) |
|
||||||
* [.loadDatabaseAsync()](#Datastore+loadDatabaseAsync) ⇒ <code>Promise</code> |
|
||||||
* [.getAllData()](#Datastore+getAllData) ⇒ [<code>Array.<document></code>](#document) |
|
||||||
* [.resetIndexes(newData)](#Datastore+resetIndexes) |
|
||||||
* [.ensureIndex(options, callback)](#Datastore+ensureIndex) |
|
||||||
* [.ensureIndexAsync(options)](#Datastore+ensureIndexAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.removeIndex(fieldName, callback)](#Datastore+removeIndex) |
|
||||||
* [.removeIndexAsync(fieldName)](#Datastore+removeIndexAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.addToIndexes(doc)](#Datastore+addToIndexes) |
|
||||||
* [.removeFromIndexes(doc)](#Datastore+removeFromIndexes) |
|
||||||
* [.updateIndexes(oldDoc, [newDoc])](#Datastore+updateIndexes) |
|
||||||
* [.getCandidates(query, [dontExpireStaleDocs], callback)](#Datastore+getCandidates) |
|
||||||
* [.getCandidatesAsync(query, [dontExpireStaleDocs])](#Datastore+getCandidatesAsync) ⇒ <code>Promise.<Array.<document>></code> |
|
||||||
* [.insertAsync(newDoc)](#Datastore+insertAsync) ⇒ [<code>Promise.<document></code>](#document) |
|
||||||
* [.count(query, [callback])](#Datastore+count) ⇒ <code>Cursor.<number></code> \| <code>undefined</code> |
|
||||||
* [.countAsync(query)](#Datastore+countAsync) ⇒ <code>Cursor.<number></code> |
|
||||||
* [.find(query, [projection], [callback])](#Datastore+find) ⇒ <code>Cursor.<Array.<document>></code> \| <code>undefined</code> |
|
||||||
* [.findAsync(query, [projection])](#Datastore+findAsync) ⇒ <code>Cursor.<Array.<document>></code> |
|
||||||
* [.findOne(query, [projection], [callback])](#Datastore+findOne) ⇒ [<code>Cursor.<document></code>](#document) \| <code>undefined</code> |
|
||||||
* [.findOneAsync(query, projection)](#Datastore+findOneAsync) ⇒ [<code>Cursor.<document></code>](#document) |
|
||||||
* [.update(query, update, [options|], [cb])](#Datastore+update) |
|
||||||
* [.updateAsync(query, update, [options])](#Datastore+updateAsync) ⇒ <code>Promise.<{numAffected: number, affectedDocuments: (Array.<document>\|document\|null), upsert: boolean}></code> |
|
||||||
* [.remove(query, [options], [cb])](#Datastore+remove) |
|
||||||
* [.removeAsync(query, [options])](#Datastore+removeAsync) ⇒ <code>Promise.<number></code> |
|
||||||
* ["event:compaction.done"](#Datastore+event_compaction.done) |
|
||||||
* _inner_ |
|
||||||
* [~countCallback](#Datastore..countCallback) : <code>function</code> |
|
||||||
* [~findOneCallback](#Datastore..findOneCallback) : <code>function</code> |
|
||||||
* [~updateCallback](#Datastore..updateCallback) : <code>function</code> |
|
||||||
* [~removeCallback](#Datastore..removeCallback) : <code>function</code> |
|
||||||
|
|
||||||
<a name="new_Datastore_new"></a> |
|
||||||
|
|
||||||
### new Datastore(options) |
|
||||||
<p>Create a new collection, either persistent or in-memory.</p> |
|
||||||
<p>If you use a persistent datastore without the <code>autoload</code> option, you need to call <code>loadDatabase</code> manually. This |
|
||||||
function fetches the data from datafile and prepares the database. <strong>Don't forget it!</strong> If you use a persistent |
|
||||||
datastore, no command (insert, find, update, remove) will be executed before <code>loadDatabase</code> is called, so make sure |
|
||||||
to call it yourself or use the <code>autoload</code> option.</p> |
|
||||||
|
|
||||||
**Params** |
|
||||||
|
|
||||||
- options <code>object</code> | <code>string</code> - <p>Can be an object or a string. If options is a string, the behavior is the same as in |
|
||||||
v0.6: it will be interpreted as <code>options.filename</code>. <strong>Giving a string is deprecated, and will be removed in the |
|
||||||
next major version.</strong></p> |
|
||||||
- [.filename] <code>string</code> <code> = null</code> - <p>Path to the file where the data is persisted. If left blank, the datastore is |
|
||||||
automatically considered in-memory only. It cannot end with a <code>~</code> which is used in the temporary files NeDB uses to |
|
||||||
perform crash-safe writes.</p> |
|
||||||
- [.inMemoryOnly] <code>boolean</code> <code> = false</code> - <p>If set to true, no data will be written in storage.</p> |
|
||||||
- [.timestampData] <code>boolean</code> <code> = false</code> - <p>If set to true, createdAt and updatedAt will be created and |
|
||||||
populated automatically (if not specified by user)</p> |
|
||||||
- [.autoload] <code>boolean</code> <code> = false</code> - <p>If used, the database will automatically be loaded from the datafile |
|
||||||
upon creation (you don't need to call <code>loadDatabase</code>). Any command issued before load is finished is buffered and |
|
||||||
will be executed when load is done. When autoloading is done, you can either use the <code>onload</code> callback, or you can |
|
||||||
use <code>this.autoloadPromise</code> which resolves (or rejects) when autloading is done.</p> |
|
||||||
- [.onload] <code>function</code> - <p>If you use autoloading, this is the handler called after the <code>loadDatabase</code>. It |
|
||||||
takes one <code>error</code> argument. If you use autoloading without specifying this handler, and an error happens during |
|
||||||
load, an error will be thrown.</p> |
|
||||||
- [.beforeDeserialization] <code>function</code> - <p>Hook you can use to transform data after it was serialized and |
|
||||||
before it is written to disk. Can be used for example to encrypt data before writing database to disk. This |
|
||||||
function takes a string as parameter (one line of an NeDB data file) and outputs the transformed string, <strong>which |
|
||||||
must absolutely not contain a <code>\n</code> character</strong> (or data will be lost).</p> |
|
||||||
- [.afterSerialization] <code>function</code> - <p>Inverse of <code>afterSerialization</code>. Make sure to include both and not |
|
||||||
just one, or you risk data loss. For the same reason, make sure both functions are inverses of one another. Some |
|
||||||
failsafe mechanisms are in place to prevent data loss if you misuse the serialization hooks: NeDB checks that never |
|
||||||
one is declared without the other, and checks that they are reverse of one another by testing on random strings of |
|
||||||
various lengths. In addition, if too much data is detected as corrupt, NeDB will refuse to start as it could mean |
|
||||||
you're not using the deserialization hook corresponding to the serialization hook used before.</p> |
|
||||||
- [.corruptAlertThreshold] <code>number</code> <code> = 0.1</code> - <p>Between 0 and 1, defaults to 10%. NeDB will refuse to start |
|
||||||
if more than this percentage of the datafile is corrupt. 0 means you don't tolerate any corruption, 1 means you |
|
||||||
don't care.</p> |
|
||||||
- [.compareStrings] [<code>compareStrings</code>](#compareStrings) - <p>If specified, it overrides default string comparison which is not |
|
||||||
well adapted to non-US characters in particular accented letters. Native <code>localCompare</code> will most of the time be |
|
||||||
the right choice.</p> |
|
||||||
- [.nodeWebkitAppName] <code>string</code> - <p><strong>Deprecated:</strong> if you are using NeDB from whithin a Node Webkit app, |
|
||||||
specify its name (the same one you use in the <code>package.json</code>) in this field and the <code>filename</code> will be relative to |
|
||||||
the directory Node Webkit uses to store the rest of the application's data (local storage etc.). It works on Linux, |
|
||||||
OS X and Windows. Now that you can use <code>require('nw.gui').App.dataPath</code> in Node Webkit to get the path to the data |
|
||||||
directory for your application, you should not use this option anymore and it will be removed.</p> |
|
||||||
|
|
||||||
<a name="Datastore+inMemoryOnly"></a> |
|
||||||
|
|
||||||
### datastore.inMemoryOnly : <code>boolean</code> |
|
||||||
<p>Determines if the <code>Datastore</code> keeps data in-memory, or if it saves it in storage. Is not read after |
|
||||||
instanciation.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
<a name="Datastore+autoload"></a> |
|
||||||
|
|
||||||
### datastore.autoload : <code>boolean</code> |
|
||||||
<p>Determines if the <code>Datastore</code> should autoload the database upon instantiation. Is not read after instanciation.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
<a name="Datastore+timestampData"></a> |
|
||||||
|
|
||||||
### datastore.timestampData : <code>boolean</code> |
|
||||||
<p>Determines if the <code>Datastore</code> should add <code>createdAt</code> and <code>updatedAt</code> fields automatically if not set by the user.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
<a name="Datastore+filename"></a> |
|
||||||
|
|
||||||
### datastore.filename : <code>string</code> |
|
||||||
<p>If null, it means <code>inMemoryOnly</code> is <code>true</code>. The <code>filename</code> is the name given to the storage module. Is not read |
|
||||||
after instanciation.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
<a name="Datastore+persistence"></a> |
|
||||||
|
|
||||||
### datastore.persistence : [<code>Persistence</code>](#Persistence) |
|
||||||
<p>The <code>Persistence</code> instance for this <code>Datastore</code>.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Datastore</code>](#Datastore) |
|
||||||
<a name="Datastore+executor"></a> |
|
||||||
|
|
||||||
### datastore.executor : [<code>Executor</code>](#Executor) |
|
||||||
<p>The <code>Executor</code> instance for this <code>Datastore</code>. It is used in all methods exposed by the <code>Datastore</code>, any <code>Cursor</code> |
|
||||||
produced by the <code>Datastore</code> and by <code>this.persistence.compactDataFile</code> & <code>this.persistence.compactDataFileAsync</code> |
|
||||||
to ensure operations are performed sequentially in the database.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
<a name="Datastore+indexes"></a> |
|
||||||
|
|
||||||
### datastore.indexes : <code>Object.<string, Index></code> |
|
||||||
<p>Indexed by field name, dot notation can be used. |
|
||||||
_id is always indexed and since _ids are generated randomly the underlying binary search tree is always well-balanced</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
<a name="Datastore+ttlIndexes"></a> |
|
||||||
|
|
||||||
### datastore.ttlIndexes : <code>Object.<string, number></code> |
|
||||||
<p>Stores the time to live (TTL) of the indexes created. The key represents the field name, the value the number of |
|
||||||
seconds after which data with this index field should be removed.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
<a name="Datastore+autoloadPromise"></a> |
|
||||||
|
|
||||||
### datastore.autoloadPromise : <code>Promise</code> |
|
||||||
<p>A Promise that resolves when the autoload has finished.</p> |
|
||||||
<p>The onload callback is not awaited by this Promise, it is started immediately after that.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Datastore</code>](#Datastore) |
|
||||||
<a name="Datastore+compareStrings"></a> |
|
||||||
|
|
||||||
### datastore.compareStrings() : [<code>compareStrings</code>](#compareStrings) |
|
||||||
<p>Overrides default string comparison which is not well adapted to non-US characters in particular accented |
|
||||||
letters. Native <code>localCompare</code> will most of the time be the right choice</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
<a name="Datastore+loadDatabase"></a> |
|
||||||
|
|
||||||
### datastore.loadDatabase(callback) |
|
||||||
<p>Load the database from the datafile, and trigger the execution of buffered commands if any.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="Datastore+loadDatabaseAsync"></a> |
|
||||||
|
|
||||||
### datastore.loadDatabaseAsync() ⇒ <code>Promise</code> |
|
||||||
<p>Async version of [loadDatabase](#Datastore+loadDatabase).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**See**: Datastore#loadDatabase |
|
||||||
<a name="Datastore+getAllData"></a> |
|
||||||
|
|
||||||
### datastore.getAllData() ⇒ [<code>Array.<document></code>](#document) |
|
||||||
<p>Get an array of all the data in the database.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
<a name="Datastore+resetIndexes"></a> |
|
||||||
|
|
||||||
### datastore.resetIndexes(newData) |
|
||||||
<p>Reset all currently defined indexes.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- newData [<code>document</code>](#document) | [<code>?Array.<document></code>](#document) |
|
||||||
|
|
||||||
<a name="Datastore+ensureIndex"></a> |
|
||||||
|
|
||||||
### datastore.ensureIndex(options, callback) |
|
||||||
<p>Ensure an index is kept for this field. Same parameters as lib/indexes |
|
||||||
This function acts synchronously on the indexes, however the persistence of the indexes is deferred with the |
|
||||||
executor. |
|
||||||
Previous versions said explicitly the callback was optional, it is now recommended setting one.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- options <code>object</code> |
|
||||||
- .fieldName <code>string</code> - <p>Name of the field to index. Use the dot notation to index a field in a nested document.</p> |
|
||||||
- [.unique] <code>boolean</code> <code> = false</code> - <p>Enforce field uniqueness. Note that a unique index will raise an error if you try to index two documents for which the field is not defined.</p> |
|
||||||
- [.sparse] <code>boolean</code> <code> = false</code> - <p>don't index documents for which the field is not defined. Use this option along with "unique" if you want to accept multiple documents for which it is not defined.</p> |
|
||||||
- [.expireAfterSeconds] <code>number</code> - <p>if set, the created index is a TTL (time to live) index, that will automatically remove documents when the system date becomes larger than the date on the indexed field plus <code>expireAfterSeconds</code>. Documents where the indexed field is not specified or not a <code>Date</code> object are ignored</p> |
|
||||||
- callback [<code>NoParamCallback</code>](#NoParamCallback) - <p>Callback, signature: err</p> |
|
||||||
|
|
||||||
<a name="Datastore+ensureIndexAsync"></a> |
|
||||||
|
|
||||||
### datastore.ensureIndexAsync(options) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [ensureIndex](#Datastore+ensureIndex).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**See**: Datastore#ensureIndex |
|
||||||
**Params** |
|
||||||
|
|
||||||
- options <code>object</code> |
|
||||||
- .fieldName <code>string</code> - <p>Name of the field to index. Use the dot notation to index a field in a nested document.</p> |
|
||||||
- [.unique] <code>boolean</code> <code> = false</code> - <p>Enforce field uniqueness. Note that a unique index will raise an error if you try to index two documents for which the field is not defined.</p> |
|
||||||
- [.sparse] <code>boolean</code> <code> = false</code> - <p>Don't index documents for which the field is not defined. Use this option along with "unique" if you want to accept multiple documents for which it is not defined.</p> |
|
||||||
- [.expireAfterSeconds] <code>number</code> - <p>If set, the created index is a TTL (time to live) index, that will automatically remove documents when the system date becomes larger than the date on the indexed field plus <code>expireAfterSeconds</code>. Documents where the indexed field is not specified or not a <code>Date</code> object are ignored</p> |
|
||||||
|
|
||||||
<a name="Datastore+removeIndex"></a> |
|
||||||
|
|
||||||
### datastore.removeIndex(fieldName, callback) |
|
||||||
<p>Remove an index |
|
||||||
Previous versions said explicitly the callback was optional, it is now recommended setting one.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- fieldName <code>string</code> - <p>Field name of the index to remove. Use the dot notation to remove an index referring to a |
|
||||||
field in a nested document.</p> |
|
||||||
- callback [<code>NoParamCallback</code>](#NoParamCallback) - <p>Optional callback, signature: err</p> |
|
||||||
|
|
||||||
<a name="Datastore+removeIndexAsync"></a> |
|
||||||
|
|
||||||
### datastore.removeIndexAsync(fieldName) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [removeIndex](#Datastore+removeIndex).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**See**: Datastore#removeIndex |
|
||||||
**Params** |
|
||||||
|
|
||||||
- fieldName <code>string</code> - <p>Field name of the index to remove. Use the dot notation to remove an index referring to a |
|
||||||
field in a nested document.</p> |
|
||||||
|
|
||||||
<a name="Datastore+addToIndexes"></a> |
|
||||||
|
|
||||||
### datastore.addToIndexes(doc) |
|
||||||
<p>Add one or several document(s) to all indexes.</p> |
|
||||||
<p>This is an internal function.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
**Params** |
|
||||||
|
|
||||||
- doc [<code>document</code>](#document) |
|
||||||
|
|
||||||
<a name="Datastore+removeFromIndexes"></a> |
|
||||||
|
|
||||||
### datastore.removeFromIndexes(doc) |
|
||||||
<p>Remove one or several document(s) from all indexes.</p> |
|
||||||
<p>This is an internal function.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
**Params** |
|
||||||
|
|
||||||
- doc [<code>document</code>](#document) |
|
||||||
|
|
||||||
<a name="Datastore+updateIndexes"></a> |
|
||||||
|
|
||||||
### datastore.updateIndexes(oldDoc, [newDoc]) |
|
||||||
<p>Update one or several documents in all indexes.</p> |
|
||||||
<p>To update multiple documents, oldDoc must be an array of { oldDoc, newDoc } pairs.</p> |
|
||||||
<p>If one update violates a constraint, all changes are rolled back.</p> |
|
||||||
<p>This is an internal function.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- oldDoc [<code>document</code>](#document) | <code>Array.<{oldDoc: document, newDoc: document}></code> - <p>Document to update, or an <code>Array</code> of |
|
||||||
<code>{oldDoc, newDoc}</code> pairs.</p> |
|
||||||
- [newDoc] [<code>document</code>](#document) - <p>Document to replace the oldDoc with. If the first argument is an <code>Array</code> of |
|
||||||
<code>{oldDoc, newDoc}</code> pairs, this second argument is ignored.</p> |
|
||||||
|
|
||||||
<a name="Datastore+getCandidates"></a> |
|
||||||
|
|
||||||
### datastore.getCandidates(query, [dontExpireStaleDocs], callback) |
|
||||||
<p>Return the list of candidates for a given query |
|
||||||
Crude implementation for now, we return the candidates given by the first usable index if any |
|
||||||
We try the following query types, in this order: basic match, $in match, comparison match |
|
||||||
One way to make it better would be to enable the use of multiple indexes if the first usable index |
|
||||||
returns too much data. I may do it in the future.</p> |
|
||||||
<p>Returned candidates will be scanned to find and remove all expired documents</p> |
|
||||||
<p>This is an internal function.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Access**: protected |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) |
|
||||||
- [dontExpireStaleDocs] <code>boolean</code> | <code>function</code> <code> = false</code> - <p>If true don't remove stale docs. Useful for the remove |
|
||||||
function which shouldn't be impacted by expirations. If argument is not given, it is used as the callback.</p> |
|
||||||
- callback [<code>MultipleDocumentsCallback</code>](#MultipleDocumentsCallback) - <p>Signature err, candidates</p> |
|
||||||
|
|
||||||
<a name="Datastore+getCandidatesAsync"></a> |
|
||||||
|
|
||||||
### datastore.getCandidatesAsync(query, [dontExpireStaleDocs]) ⇒ <code>Promise.<Array.<document>></code> |
|
||||||
<p>Async version of [getCandidates](#Datastore+getCandidates).</p> |
|
||||||
<p>This is an internal function.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Returns**: <code>Promise.<Array.<document>></code> - <p>candidates</p> |
|
||||||
**Access**: protected |
|
||||||
**See**: Datastore#getCandidates |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) |
|
||||||
- [dontExpireStaleDocs] <code>boolean</code> <code> = false</code> - <p>If true don't remove stale docs. Useful for the remove function |
|
||||||
which shouldn't be impacted by expirations.</p> |
|
||||||
|
|
||||||
<a name="Datastore+insertAsync"></a> |
|
||||||
|
|
||||||
### datastore.insertAsync(newDoc) ⇒ [<code>Promise.<document></code>](#document) |
|
||||||
<p>Async version of [Datastore#insert](Datastore#insert).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- newDoc [<code>document</code>](#document) | [<code>Array.<document></code>](#document) |
|
||||||
|
|
||||||
<a name="Datastore+count"></a> |
|
||||||
|
|
||||||
### datastore.count(query, [callback]) ⇒ <code>Cursor.<number></code> \| <code>undefined</code> |
|
||||||
<p>Count all documents matching the query.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) - <p>MongoDB-style query</p> |
|
||||||
- [callback] [<code>countCallback</code>](#Datastore..countCallback) - <p>If given, the function will return undefined, otherwise it will return the Cursor.</p> |
|
||||||
|
|
||||||
<a name="Datastore+countAsync"></a> |
|
||||||
|
|
||||||
### datastore.countAsync(query) ⇒ <code>Cursor.<number></code> |
|
||||||
<p>Async version of [count](#Datastore+count).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Returns**: <code>Cursor.<number></code> - <p>count</p> |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) - <p>MongoDB-style query</p> |
|
||||||
|
|
||||||
<a name="Datastore+find"></a> |
|
||||||
|
|
||||||
### datastore.find(query, [projection], [callback]) ⇒ <code>Cursor.<Array.<document>></code> \| <code>undefined</code> |
|
||||||
<p>Find all documents matching the query |
|
||||||
If no callback is passed, we return the cursor so that user can limit, skip and finally exec</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) - <p>MongoDB-style query</p> |
|
||||||
- [projection] [<code>projection</code>](#projection) | [<code>MultipleDocumentsCallback</code>](#MultipleDocumentsCallback) <code> = {}</code> - <p>MongoDB-style projection. If not given, will be |
|
||||||
interpreted as the callback.</p> |
|
||||||
- [callback] [<code>MultipleDocumentsCallback</code>](#MultipleDocumentsCallback) - <p>Optional callback, signature: err, docs</p> |
|
||||||
|
|
||||||
<a name="Datastore+findAsync"></a> |
|
||||||
|
|
||||||
### datastore.findAsync(query, [projection]) ⇒ <code>Cursor.<Array.<document>></code> |
|
||||||
<p>Async version of [find](#Datastore+find).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) - <p>MongoDB-style query</p> |
|
||||||
- [projection] [<code>projection</code>](#projection) <code> = {}</code> - <p>MongoDB-style projection</p> |
|
||||||
|
|
||||||
<a name="Datastore+findOne"></a> |
|
||||||
|
|
||||||
### datastore.findOne(query, [projection], [callback]) ⇒ [<code>Cursor.<document></code>](#document) \| <code>undefined</code> |
|
||||||
<p>Find one document matching the query.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) - <p>MongoDB-style query</p> |
|
||||||
- [projection] [<code>projection</code>](#projection) | [<code>SingleDocumentCallback</code>](#SingleDocumentCallback) <code> = {}</code> - <p>MongoDB-style projection</p> |
|
||||||
- [callback] [<code>SingleDocumentCallback</code>](#SingleDocumentCallback) - <p>Optional callback, signature: err, doc</p> |
|
||||||
|
|
||||||
<a name="Datastore+findOneAsync"></a> |
|
||||||
|
|
||||||
### datastore.findOneAsync(query, projection) ⇒ [<code>Cursor.<document></code>](#document) |
|
||||||
<p>Async version of [findOne](#Datastore+findOne).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**See**: Datastore#findOne |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) - <p>MongoDB-style query</p> |
|
||||||
- projection [<code>projection</code>](#projection) - <p>MongoDB-style projection</p> |
|
||||||
|
|
||||||
<a name="Datastore+update"></a> |
|
||||||
|
|
||||||
### datastore.update(query, update, [options|], [cb]) |
|
||||||
<p>Update all docs matching query.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) - <p>is the same kind of finding query you use with <code>find</code> and <code>findOne</code></p> |
|
||||||
- update [<code>document</code>](#document) | <code>\*</code> - <p>specifies how the documents should be modified. It is either a new document or a |
|
||||||
set of modifiers (you cannot use both together, it doesn't make sense!). Using a new document will replace the |
|
||||||
matched docs. Using a set of modifiers will create the fields they need to modify if they don't exist, and you can |
|
||||||
apply them to subdocs. Available field modifiers are <code>$set</code> to change a field's value, <code>$unset</code> to delete a field, |
|
||||||
<code>$inc</code> to increment a field's value and <code>$min</code>/<code>$max</code> to change field's value, only if provided value is |
|
||||||
less/greater than current value. To work on arrays, you have <code>$push</code>, <code>$pop</code>, <code>$addToSet</code>, <code>$pull</code>, and the special |
|
||||||
<code>$each</code> and <code>$slice</code>.</p> |
|
||||||
- [options|] <code>Object</code> | [<code>updateCallback</code>](#Datastore..updateCallback) - <p>Optional options</p> |
|
||||||
- [.multi] <code>boolean</code> <code> = false</code> - <p>If true, can update multiple documents</p> |
|
||||||
- [.upsert] <code>boolean</code> <code> = false</code> - <p>If true, can insert a new document corresponding to the <code>update</code> rules if |
|
||||||
your <code>query</code> doesn't match anything. If your <code>update</code> is a simple object with no modifiers, it is the inserted |
|
||||||
document. In the other case, the <code>query</code> is stripped from all operator recursively, and the <code>update</code> is applied to |
|
||||||
it.</p> |
|
||||||
- [.returnUpdatedDocs] <code>boolean</code> <code> = false</code> - <p>(not Mongo-DB compatible) If true and update is not an upsert, |
|
||||||
will return the array of documents matched by the find query and updated. Updated documents will be returned even |
|
||||||
if the update did not actually modify them.</p> |
|
||||||
- [cb] [<code>updateCallback</code>](#Datastore..updateCallback) <code> = () => {}</code> - <p>Optional callback</p> |
|
||||||
|
|
||||||
<a name="Datastore+updateAsync"></a> |
|
||||||
|
|
||||||
### datastore.updateAsync(query, update, [options]) ⇒ <code>Promise.<{numAffected: number, affectedDocuments: (Array.<document>\|document\|null), upsert: boolean}></code> |
|
||||||
<p>Async version of [update](#Datastore+update).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**See**: Datastore#update |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) - <p>is the same kind of finding query you use with <code>find</code> and <code>findOne</code></p> |
|
||||||
- update [<code>document</code>](#document) | <code>\*</code> - <p>specifies how the documents should be modified. It is either a new document or a |
|
||||||
set of modifiers (you cannot use both together, it doesn't make sense!). Using a new document will replace the |
|
||||||
matched docs. Using a set of modifiers will create the fields they need to modify if they don't exist, and you can |
|
||||||
apply them to subdocs. Available field modifiers are <code>$set</code> to change a field's value, <code>$unset</code> to delete a field, |
|
||||||
<code>$inc</code> to increment a field's value and <code>$min</code>/<code>$max</code> to change field's value, only if provided value is |
|
||||||
less/greater than current value. To work on arrays, you have <code>$push</code>, <code>$pop</code>, <code>$addToSet</code>, <code>$pull</code>, and the special |
|
||||||
<code>$each</code> and <code>$slice</code>.</p> |
|
||||||
- [options] <code>Object</code> <code> = {}</code> - <p>Optional options</p> |
|
||||||
- [.multi] <code>boolean</code> <code> = false</code> - <p>If true, can update multiple documents</p> |
|
||||||
- [.upsert] <code>boolean</code> <code> = false</code> - <p>If true, can insert a new document corresponding to the <code>update</code> rules if |
|
||||||
your <code>query</code> doesn't match anything. If your <code>update</code> is a simple object with no modifiers, it is the inserted |
|
||||||
document. In the other case, the <code>query</code> is stripped from all operator recursively, and the <code>update</code> is applied to |
|
||||||
it.</p> |
|
||||||
- [.returnUpdatedDocs] <code>boolean</code> <code> = false</code> - <p>(not Mongo-DB compatible) If true and update is not an upsert, |
|
||||||
will return the array of documents matched by the find query and updated. Updated documents will be returned even |
|
||||||
if the update did not actually modify them.</p> |
|
||||||
|
|
||||||
<a name="Datastore+remove"></a> |
|
||||||
|
|
||||||
### datastore.remove(query, [options], [cb]) |
|
||||||
<p>Remove all docs matching the query.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) |
|
||||||
- [options] <code>object</code> | [<code>removeCallback</code>](#Datastore..removeCallback) <code> = {}</code> - <p>Optional options</p> |
|
||||||
- [.multi] <code>boolean</code> <code> = false</code> - <p>If true, can update multiple documents</p> |
|
||||||
- [cb] [<code>removeCallback</code>](#Datastore..removeCallback) <code> = () => {}</code> - <p>Optional callback</p> |
|
||||||
|
|
||||||
<a name="Datastore+removeAsync"></a> |
|
||||||
|
|
||||||
### datastore.removeAsync(query, [options]) ⇒ <code>Promise.<number></code> |
|
||||||
<p>Remove all docs matching the query. |
|
||||||
Use Datastore.removeAsync which has the same signature</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) |
|
||||||
**Returns**: <code>Promise.<number></code> - <p>How many documents were removed</p> |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query [<code>query</code>](#query) |
|
||||||
- [options] <code>object</code> <code> = {}</code> - <p>Optional options</p> |
|
||||||
- [.multi] <code>boolean</code> <code> = false</code> - <p>If true, can update multiple documents</p> |
|
||||||
|
|
||||||
<a name="Datastore+event_compaction.done"></a> |
|
||||||
|
|
||||||
### "event:compaction.done" |
|
||||||
<p>Compaction event. Happens when the Datastore's Persistence has been compacted. |
|
||||||
It happens when calling <code>datastore.persistence.compactDatafile</code>, which is called periodically if you have called |
|
||||||
<code>datastore.persistence.setAutocompactionInterval</code>.</p> |
|
||||||
|
|
||||||
**Kind**: event emitted by [<code>Datastore</code>](#Datastore) |
|
||||||
<a name="Datastore..countCallback"></a> |
|
||||||
|
|
||||||
### Datastore~countCallback : <code>function</code> |
|
||||||
**Kind**: inner typedef of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- err <code>Error</code> |
|
||||||
- count <code>number</code> |
|
||||||
|
|
||||||
<a name="Datastore..findOneCallback"></a> |
|
||||||
|
|
||||||
### Datastore~findOneCallback : <code>function</code> |
|
||||||
**Kind**: inner typedef of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- err <code>Error</code> |
|
||||||
- doc [<code>document</code>](#document) |
|
||||||
|
|
||||||
<a name="Datastore..updateCallback"></a> |
|
||||||
|
|
||||||
### Datastore~updateCallback : <code>function</code> |
|
||||||
<p>If update was an upsert, <code>upsert</code> flag is set to true, <code>affectedDocuments</code> can be one of the following:</p> |
|
||||||
<ul> |
|
||||||
<li>For an upsert, the upserted document</li> |
|
||||||
<li>For an update with returnUpdatedDocs option false, null</li> |
|
||||||
<li>For an update with returnUpdatedDocs true and multi false, the updated document</li> |
|
||||||
<li>For an update with returnUpdatedDocs true and multi true, the array of updated documents</li> |
|
||||||
</ul> |
|
||||||
<p><strong>WARNING:</strong> The API was changed between v1.7.4 and v1.8, for consistency and readability reasons. Prior and |
|
||||||
including to v1.7.4, the callback signature was (err, numAffected, updated) where updated was the updated document |
|
||||||
in case of an upsert or the array of updated documents for an update if the returnUpdatedDocs option was true. That |
|
||||||
meant that the type of affectedDocuments in a non multi update depended on whether there was an upsert or not, |
|
||||||
leaving only two ways for the user to check whether an upsert had occured: checking the type of affectedDocuments |
|
||||||
or running another find query on the whole dataset to check its size. Both options being ugly, the breaking change |
|
||||||
was necessary.</p> |
|
||||||
|
|
||||||
**Kind**: inner typedef of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- err <code>Error</code> |
|
||||||
- numAffected <code>number</code> |
|
||||||
- affectedDocuments [<code>?Array.<document></code>](#document) | [<code>document</code>](#document) |
|
||||||
- upsert <code>boolean</code> |
|
||||||
|
|
||||||
<a name="Datastore..removeCallback"></a> |
|
||||||
|
|
||||||
### Datastore~removeCallback : <code>function</code> |
|
||||||
**Kind**: inner typedef of [<code>Datastore</code>](#Datastore) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- err <code>Error</code> |
|
||||||
- numRemoved <code>number</code> |
|
||||||
|
|
@ -1,57 +0,0 @@ |
|||||||
<a name="Executor"></a> |
|
||||||
|
|
||||||
## Executor |
|
||||||
<p>Executes operations sequentially. |
|
||||||
Has an option for a buffer that can be triggered afterwards.</p> |
|
||||||
|
|
||||||
**Kind**: global class |
|
||||||
|
|
||||||
* [Executor](#Executor) |
|
||||||
* [new Executor()](#new_Executor_new) |
|
||||||
* [.push(task, [forceQueuing])](#Executor+push) |
|
||||||
* [.pushAsync(task, [forceQueuing])](#Executor+pushAsync) ⇒ <code>Promise.<\*></code> |
|
||||||
* [.processBuffer()](#Executor+processBuffer) |
|
||||||
|
|
||||||
<a name="new_Executor_new"></a> |
|
||||||
|
|
||||||
### new Executor() |
|
||||||
<p>Instantiates a new Executor.</p> |
|
||||||
|
|
||||||
<a name="Executor+push"></a> |
|
||||||
|
|
||||||
### executor.push(task, [forceQueuing]) |
|
||||||
<p>If executor is ready, queue task (and process it immediately if executor was idle) |
|
||||||
If not, buffer task for later processing</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Executor</code>](#Executor) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- task <code>Object</code> |
|
||||||
- .this <code>Object</code> - <p>Object to use as this</p> |
|
||||||
- .fn <code>function</code> - <p>Function to execute</p> |
|
||||||
- .arguments <code>Array</code> - <p>Array of arguments, IMPORTANT: only the last argument may be a function |
|
||||||
(the callback) and the last argument cannot be false/undefined/null</p> |
|
||||||
- [forceQueuing] <code>Boolean</code> <code> = false</code> - <p>Optional (defaults to false) force executor to queue task even if it is not ready</p> |
|
||||||
|
|
||||||
<a name="Executor+pushAsync"></a> |
|
||||||
|
|
||||||
### executor.pushAsync(task, [forceQueuing]) ⇒ <code>Promise.<\*></code> |
|
||||||
<p>Async version of [push](#Executor+push). |
|
||||||
This version is way simpler than its callbackEquivalent: you give it an async function <code>task</code>, it is executed when |
|
||||||
all the previous tasks are done, and then resolves or rejects and when it is finished with its original result or |
|
||||||
error.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Executor</code>](#Executor) |
|
||||||
**See**: Executor#push |
|
||||||
**Params** |
|
||||||
|
|
||||||
- task [<code>AsyncFunction</code>](#AsyncFunction) |
|
||||||
- [forceQueuing] <code>boolean</code> <code> = false</code> |
|
||||||
|
|
||||||
<a name="Executor+processBuffer"></a> |
|
||||||
|
|
||||||
### executor.processBuffer() |
|
||||||
<p>Queue all tasks in buffer (in the same order they came in) |
|
||||||
Automatically sets executor as ready</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Executor</code>](#Executor) |
|
@ -1,161 +0,0 @@ |
|||||||
<a name="Index"></a> |
|
||||||
|
|
||||||
## Index |
|
||||||
<p>Indexes on field names, with atomic operations and which can optionally enforce a unique constraint or allow indexed |
|
||||||
fields to be undefined</p> |
|
||||||
|
|
||||||
**Kind**: global class |
|
||||||
|
|
||||||
* [Index](#Index) |
|
||||||
* [new Index(options)](#new_Index_new) |
|
||||||
* [.fieldName](#Index+fieldName) : <code>string</code> |
|
||||||
* [.unique](#Index+unique) : <code>boolean</code> |
|
||||||
* [.sparse](#Index+sparse) : <code>boolean</code> |
|
||||||
* [.treeOptions](#Index+treeOptions) : <code>Object</code> |
|
||||||
* [.tree](#Index+tree) : <code>AVLTree</code> |
|
||||||
* [.reset([newData])](#Index+reset) |
|
||||||
* [.insert(doc)](#Index+insert) |
|
||||||
* [.remove(doc)](#Index+remove) |
|
||||||
* [.update(oldDoc, [newDoc])](#Index+update) |
|
||||||
* [.revertUpdate(oldDoc, [newDoc])](#Index+revertUpdate) |
|
||||||
* [.getMatching(value)](#Index+getMatching) ⇒ [<code>Array.<document></code>](#document) |
|
||||||
* [.getBetweenBounds(query)](#Index+getBetweenBounds) ⇒ [<code>Array.<document></code>](#document) |
|
||||||
* [.getAll()](#Index+getAll) ⇒ [<code>Array.<document></code>](#document) |
|
||||||
|
|
||||||
<a name="new_Index_new"></a> |
|
||||||
|
|
||||||
### new Index(options) |
|
||||||
<p>Create a new index |
|
||||||
All methods on an index guarantee that either the whole operation was successful and the index changed |
|
||||||
or the operation was unsuccessful and an error is thrown while the index is unchanged</p> |
|
||||||
|
|
||||||
**Params** |
|
||||||
|
|
||||||
- options <code>object</code> |
|
||||||
- .fieldName <code>string</code> - <p>On which field should the index apply (can use dot notation to index on sub fields)</p> |
|
||||||
- [.unique] <code>boolean</code> <code> = false</code> - <p>Enforces a unique constraint</p> |
|
||||||
- [.sparse] <code>boolean</code> <code> = false</code> - <p>Allows a sparse index (we can have documents for which fieldName is <code>undefined</code>)</p> |
|
||||||
|
|
||||||
<a name="Index+fieldName"></a> |
|
||||||
|
|
||||||
### index.fieldName : <code>string</code> |
|
||||||
<p>On which field the index applies to (may use dot notation to index on sub fields).</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Index</code>](#Index) |
|
||||||
<a name="Index+unique"></a> |
|
||||||
|
|
||||||
### index.unique : <code>boolean</code> |
|
||||||
<p>Defines if the index enforces a unique constraint for this index.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Index</code>](#Index) |
|
||||||
<a name="Index+sparse"></a> |
|
||||||
|
|
||||||
### index.sparse : <code>boolean</code> |
|
||||||
<p>Defines if we can have documents for which fieldName is <code>undefined</code></p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Index</code>](#Index) |
|
||||||
<a name="Index+treeOptions"></a> |
|
||||||
|
|
||||||
### index.treeOptions : <code>Object</code> |
|
||||||
<p>Options object given to the underlying BinarySearchTree.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Index</code>](#Index) |
|
||||||
<a name="Index+tree"></a> |
|
||||||
|
|
||||||
### index.tree : <code>AVLTree</code> |
|
||||||
<p>Underlying BinarySearchTree for this index. Uses an AVLTree for optimization.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Index</code>](#Index) |
|
||||||
<a name="Index+reset"></a> |
|
||||||
|
|
||||||
### index.reset([newData]) |
|
||||||
<p>Reset an index</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Index</code>](#Index) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- [newData] [<code>document</code>](#document) | [<code>?Array.<document></code>](#document) - <p>Data to initialize the index with. If an error is thrown during |
|
||||||
insertion, the index is not modified.</p> |
|
||||||
|
|
||||||
<a name="Index+insert"></a> |
|
||||||
|
|
||||||
### index.insert(doc) |
|
||||||
<p>Insert a new document in the index |
|
||||||
If an array is passed, we insert all its elements (if one insertion fails the index is not modified) |
|
||||||
O(log(n))</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Index</code>](#Index) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- doc [<code>document</code>](#document) | [<code>Array.<document></code>](#document) - <p>The document, or array of documents, to insert.</p> |
|
||||||
|
|
||||||
<a name="Index+remove"></a> |
|
||||||
|
|
||||||
### index.remove(doc) |
|
||||||
<p>Removes a document from the index. |
|
||||||
If an array is passed, we remove all its elements |
|
||||||
The remove operation is safe with regards to the 'unique' constraint |
|
||||||
O(log(n))</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Index</code>](#Index) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- doc [<code>Array.<document></code>](#document) | [<code>document</code>](#document) - <p>The document, or Array of documents, to remove.</p> |
|
||||||
|
|
||||||
<a name="Index+update"></a> |
|
||||||
|
|
||||||
### index.update(oldDoc, [newDoc]) |
|
||||||
<p>Update a document in the index |
|
||||||
If a constraint is violated, changes are rolled back and an error thrown |
|
||||||
Naive implementation, still in O(log(n))</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Index</code>](#Index) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- oldDoc [<code>document</code>](#document) | <code>Array.<{oldDoc: document, newDoc: document}></code> - <p>Document to update, or an <code>Array</code> of |
|
||||||
<code>{oldDoc, newDoc}</code> pairs.</p> |
|
||||||
- [newDoc] [<code>document</code>](#document) - <p>Document to replace the oldDoc with. If the first argument is an <code>Array</code> of |
|
||||||
<code>{oldDoc, newDoc}</code> pairs, this second argument is ignored.</p> |
|
||||||
|
|
||||||
<a name="Index+revertUpdate"></a> |
|
||||||
|
|
||||||
### index.revertUpdate(oldDoc, [newDoc]) |
|
||||||
<p>Revert an update</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Index</code>](#Index) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- oldDoc [<code>document</code>](#document) | <code>Array.<{oldDoc: document, newDoc: document}></code> - <p>Document to revert to, or an <code>Array</code> of <code>{oldDoc, newDoc}</code> pairs.</p> |
|
||||||
- [newDoc] [<code>document</code>](#document) - <p>Document to revert from. If the first argument is an Array of {oldDoc, newDoc}, this second argument is ignored.</p> |
|
||||||
|
|
||||||
<a name="Index+getMatching"></a> |
|
||||||
|
|
||||||
### index.getMatching(value) ⇒ [<code>Array.<document></code>](#document) |
|
||||||
<p>Get all documents in index whose key match value (if it is a Thing) or one of the elements of value (if it is an array of Things)</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Index</code>](#Index) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- value <code>Array.<\*></code> | <code>\*</code> - <p>Value to match the key against</p> |
|
||||||
|
|
||||||
<a name="Index+getBetweenBounds"></a> |
|
||||||
|
|
||||||
### index.getBetweenBounds(query) ⇒ [<code>Array.<document></code>](#document) |
|
||||||
<p>Get all documents in index whose key is between bounds are they are defined by query |
|
||||||
Documents are sorted by key</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Index</code>](#Index) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- query <code>object</code> - <p>An object with at least one matcher among $gt, $gte, $lt, $lte.</p> |
|
||||||
- [.$gt] <code>\*</code> - <p>Greater than matcher.</p> |
|
||||||
- [.$gte] <code>\*</code> - <p>Greater than or equal matcher.</p> |
|
||||||
- [.$lt] <code>\*</code> - <p>Lower than matcher.</p> |
|
||||||
- [.$lte] <code>\*</code> - <p>Lower than or equal matcher.</p> |
|
||||||
|
|
||||||
<a name="Index+getAll"></a> |
|
||||||
|
|
||||||
### index.getAll() ⇒ [<code>Array.<document></code>](#document) |
|
||||||
<p>Get all elements in the index</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Index</code>](#Index) |
|
@ -1,242 +0,0 @@ |
|||||||
<a name="Persistence"></a> |
|
||||||
|
|
||||||
## Persistence |
|
||||||
<p>Handle every persistence-related task</p> |
|
||||||
|
|
||||||
**Kind**: global class |
|
||||||
|
|
||||||
* [Persistence](#Persistence) |
|
||||||
* [new Persistence()](#new_Persistence_new) |
|
||||||
* _instance_ |
|
||||||
* [.persistCachedDatabase([callback])](#Persistence+persistCachedDatabase) |
|
||||||
* [.persistCachedDatabaseAsync()](#Persistence+persistCachedDatabaseAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.compactDatafile([callback])](#Persistence+compactDatafile) |
|
||||||
* [.compactDatafileAsync()](#Persistence+compactDatafileAsync) |
|
||||||
* [.setAutocompactionInterval(interval)](#Persistence+setAutocompactionInterval) |
|
||||||
* [.stopAutocompaction()](#Persistence+stopAutocompaction) |
|
||||||
* [.persistNewState(newDocs, [callback])](#Persistence+persistNewState) |
|
||||||
* [.persistNewStateAsync(newDocs)](#Persistence+persistNewStateAsync) ⇒ <code>Promise</code> |
|
||||||
* [.treatRawData(rawData)](#Persistence+treatRawData) ⇒ <code>Object</code> |
|
||||||
* [.treatRawStream(rawStream, cb)](#Persistence+treatRawStream) |
|
||||||
* [.treatRawStreamAsync(rawStream)](#Persistence+treatRawStreamAsync) ⇒ <code>Promise.<{data: Array.<document>, indexes: Object.<string, rawIndex>}></code> |
|
||||||
* [.loadDatabase(callback)](#Persistence+loadDatabase) |
|
||||||
* [.loadDatabaseAsync()](#Persistence+loadDatabaseAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* _static_ |
|
||||||
* [.ensureDirectoryExists(dir, [callback])](#Persistence.ensureDirectoryExists) |
|
||||||
* [.ensureDirectoryExistsAsync(dir)](#Persistence.ensureDirectoryExistsAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* ~~[.getNWAppFilename(appName, relativeFilename)](#Persistence.getNWAppFilename) ⇒ <code>string</code>~~ |
|
||||||
* _inner_ |
|
||||||
* [~treatRawStreamCallback](#Persistence..treatRawStreamCallback) : <code>function</code> |
|
||||||
|
|
||||||
<a name="new_Persistence_new"></a> |
|
||||||
|
|
||||||
### new Persistence() |
|
||||||
<p>Create a new Persistence object for database options.db</p> |
|
||||||
|
|
||||||
**Params** |
|
||||||
|
|
||||||
- .db [<code>Datastore</code>](#Datastore) |
|
||||||
- [.corruptAlertThreshold] <code>Number</code> - <p>Optional, threshold after which an alert is thrown if too much data is corrupt</p> |
|
||||||
- [.nodeWebkitAppName] <code>string</code> - <p>Optional, specify the name of your NW app if you want options.filename to be relative to the directory where Node Webkit stores application data such as cookies and local storage (the best place to store data in my opinion)</p> |
|
||||||
- [.beforeDeserialization] [<code>serializationHook</code>](#serializationHook) - <p>Hook you can use to transform data after it was serialized and before it is written to disk.</p> |
|
||||||
- [.afterSerialization] [<code>serializationHook</code>](#serializationHook) - <p>Inverse of <code>afterSerialization</code>.</p> |
|
||||||
|
|
||||||
<a name="Persistence+persistCachedDatabase"></a> |
|
||||||
|
|
||||||
### persistence.persistCachedDatabase([callback]) |
|
||||||
<p>Persist cached database |
|
||||||
This serves as a compaction function since the cache always contains only the number of documents in the collection |
|
||||||
while the data file is append-only so it may grow larger</p> |
|
||||||
<p>This is an internal function, use [compactDatafile](#Persistence+compactDatafile) which uses the [executor](#Datastore+executor).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**Access**: protected |
|
||||||
**Params** |
|
||||||
|
|
||||||
- [callback] [<code>NoParamCallback</code>](#NoParamCallback) <code> = () => {}</code> |
|
||||||
|
|
||||||
<a name="Persistence+persistCachedDatabaseAsync"></a> |
|
||||||
|
|
||||||
### persistence.persistCachedDatabaseAsync() ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [persistCachedDatabase](#Persistence+persistCachedDatabase).</p> |
|
||||||
<p>This is an internal function, use [compactDatafileAsync](#Persistence+compactDatafileAsync) which uses the [executor](#Datastore+executor).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**Access**: protected |
|
||||||
**See**: Persistence#persistCachedDatabase |
|
||||||
<a name="Persistence+compactDatafile"></a> |
|
||||||
|
|
||||||
### persistence.compactDatafile([callback]) |
|
||||||
<p>Queue a rewrite of the datafile</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**See**: Persistence#persistCachedDatabase |
|
||||||
**Params** |
|
||||||
|
|
||||||
- [callback] [<code>NoParamCallback</code>](#NoParamCallback) <code> = () => {}</code> |
|
||||||
|
|
||||||
<a name="Persistence+compactDatafileAsync"></a> |
|
||||||
|
|
||||||
### persistence.compactDatafileAsync() |
|
||||||
<p>Async version of [compactDatafile](#Persistence+compactDatafile).</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**See**: Persistence#compactDatafile |
|
||||||
<a name="Persistence+setAutocompactionInterval"></a> |
|
||||||
|
|
||||||
### persistence.setAutocompactionInterval(interval) |
|
||||||
<p>Set automatic compaction every <code>interval</code> ms</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- interval <code>Number</code> - <p>in milliseconds, with an enforced minimum of 5000 milliseconds</p> |
|
||||||
|
|
||||||
<a name="Persistence+stopAutocompaction"></a> |
|
||||||
|
|
||||||
### persistence.stopAutocompaction() |
|
||||||
<p>Stop autocompaction (do nothing if automatic compaction was not running)</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
<a name="Persistence+persistNewState"></a> |
|
||||||
|
|
||||||
### persistence.persistNewState(newDocs, [callback]) |
|
||||||
<p>Persist new state for the given newDocs (can be insertion, update or removal) |
|
||||||
Use an append-only format</p> |
|
||||||
<p>Do not use directly, it should only used by a [Datastore](#Datastore) instance.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**Access**: protected |
|
||||||
**Params** |
|
||||||
|
|
||||||
- newDocs <code>Array.<string></code> - <p>Can be empty if no doc was updated/removed</p> |
|
||||||
- [callback] [<code>NoParamCallback</code>](#NoParamCallback) <code> = () => {}</code> |
|
||||||
|
|
||||||
<a name="Persistence+persistNewStateAsync"></a> |
|
||||||
|
|
||||||
### persistence.persistNewStateAsync(newDocs) ⇒ <code>Promise</code> |
|
||||||
<p>Async version of [persistNewState](#Persistence+persistNewState)</p> |
|
||||||
<p>Do not use directly, it should only used by a [Datastore](#Datastore) instance.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**See**: Persistence#persistNewState |
|
||||||
**Params** |
|
||||||
|
|
||||||
- newDocs [<code>Array.<document></code>](#document) - <p>Can be empty if no doc was updated/removed</p> |
|
||||||
|
|
||||||
<a name="Persistence+treatRawData"></a> |
|
||||||
|
|
||||||
### persistence.treatRawData(rawData) ⇒ <code>Object</code> |
|
||||||
<p>From a database's raw data, return the corresponding machine understandable collection.</p> |
|
||||||
<p>Do not use directly, it should only used by a [Datastore](#Datastore) instance.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**Access**: protected |
|
||||||
**Params** |
|
||||||
|
|
||||||
- rawData <code>string</code> - <p>database file</p> |
|
||||||
|
|
||||||
<a name="Persistence+treatRawStream"></a> |
|
||||||
|
|
||||||
### persistence.treatRawStream(rawStream, cb) |
|
||||||
<p>From a database's raw data stream, return the corresponding machine understandable collection |
|
||||||
Is only used by a [Datastore](#Datastore) instance.</p> |
|
||||||
<p>Is only used in the Node.js version, since [React-Native](#module_storageReactNative) & |
|
||||||
[browser](#module_storageBrowser) storage modules don't provide an equivalent of |
|
||||||
[readFileStream](#module_storage.readFileStream).</p> |
|
||||||
<p>Do not use directly, it should only used by a [Datastore](#Datastore) instance.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**Access**: protected |
|
||||||
**Params** |
|
||||||
|
|
||||||
- rawStream <code>Readable</code> |
|
||||||
- cb [<code>treatRawStreamCallback</code>](#Persistence..treatRawStreamCallback) |
|
||||||
|
|
||||||
<a name="Persistence+treatRawStreamAsync"></a> |
|
||||||
|
|
||||||
### persistence.treatRawStreamAsync(rawStream) ⇒ <code>Promise.<{data: Array.<document>, indexes: Object.<string, rawIndex>}></code> |
|
||||||
<p>Async version of [treatRawStream](#Persistence+treatRawStream).</p> |
|
||||||
<p>Do not use directly, it should only used by a [Datastore](#Datastore) instance.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**Access**: protected |
|
||||||
**See**: Persistence#treatRawStream |
|
||||||
**Params** |
|
||||||
|
|
||||||
- rawStream <code>Readable</code> |
|
||||||
|
|
||||||
<a name="Persistence+loadDatabase"></a> |
|
||||||
|
|
||||||
### persistence.loadDatabase(callback) |
|
||||||
<p>Load the database</p> |
|
||||||
<ol> |
|
||||||
<li>Create all indexes</li> |
|
||||||
<li>Insert all data</li> |
|
||||||
<li>Compact the database</li> |
|
||||||
</ol> |
|
||||||
<p>This means pulling data out of the data file or creating it if it doesn't exist |
|
||||||
Also, all data is persisted right away, which has the effect of compacting the database file |
|
||||||
This operation is very quick at startup for a big collection (60ms for ~10k docs)</p> |
|
||||||
<p>Do not use directly as it does not use the [Executor](Datastore.executor), use [loadDatabase](#Datastore+loadDatabase) instead.</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**Access**: protected |
|
||||||
**Params** |
|
||||||
|
|
||||||
- callback [<code>NoParamCallback</code>](#NoParamCallback) |
|
||||||
|
|
||||||
<a name="Persistence+loadDatabaseAsync"></a> |
|
||||||
|
|
||||||
### persistence.loadDatabaseAsync() ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [loadDatabase](#Persistence+loadDatabase)</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Persistence</code>](#Persistence) |
|
||||||
**See**: Persistence#loadDatabase |
|
||||||
<a name="Persistence.ensureDirectoryExists"></a> |
|
||||||
|
|
||||||
### Persistence.ensureDirectoryExists(dir, [callback]) |
|
||||||
<p>Check if a directory stat and create it on the fly if it is not the case.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>Persistence</code>](#Persistence) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- dir <code>string</code> |
|
||||||
- [callback] [<code>NoParamCallback</code>](#NoParamCallback) <code> = () => {}</code> |
|
||||||
|
|
||||||
<a name="Persistence.ensureDirectoryExistsAsync"></a> |
|
||||||
|
|
||||||
### Persistence.ensureDirectoryExistsAsync(dir) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [ensureDirectoryExists](#Persistence.ensureDirectoryExists).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>Persistence</code>](#Persistence) |
|
||||||
**See**: Persistence.ensureDirectoryExists |
|
||||||
**Params** |
|
||||||
|
|
||||||
- dir <code>string</code> |
|
||||||
|
|
||||||
<a name="Persistence.getNWAppFilename"></a> |
|
||||||
|
|
||||||
### ~~Persistence.getNWAppFilename(appName, relativeFilename) ⇒ <code>string</code>~~ |
|
||||||
***Deprecated*** |
|
||||||
|
|
||||||
<p>Return the path the datafile if the given filename is relative to the directory where Node Webkit stores |
|
||||||
data for this application. Probably the best place to store data</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>Persistence</code>](#Persistence) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- appName <code>string</code> |
|
||||||
- relativeFilename <code>string</code> |
|
||||||
|
|
||||||
<a name="Persistence..treatRawStreamCallback"></a> |
|
||||||
|
|
||||||
### Persistence~treatRawStreamCallback : <code>function</code> |
|
||||||
**Kind**: inner typedef of [<code>Persistence</code>](#Persistence) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- err <code>Error</code> |
|
||||||
- data <code>object</code> |
|
||||||
- .data [<code>Array.<document></code>](#document) |
|
||||||
- .indexes <code>Object.<string, rawIndex></code> |
|
||||||
|
|
@ -1,43 +0,0 @@ |
|||||||
<a name="Waterfall"></a> |
|
||||||
|
|
||||||
## Waterfall |
|
||||||
<p>Responsible for sequentially executing actions on the database</p> |
|
||||||
|
|
||||||
**Kind**: global class |
|
||||||
|
|
||||||
* [Waterfall](#Waterfall) |
|
||||||
* [new Waterfall()](#new_Waterfall_new) |
|
||||||
* [.guardian](#Waterfall+guardian) ⇒ <code>Promise</code> |
|
||||||
* [.waterfall(func)](#Waterfall+waterfall) ⇒ [<code>AsyncFunction</code>](#AsyncFunction) |
|
||||||
* [.chain(promise)](#Waterfall+chain) ⇒ <code>Promise</code> |
|
||||||
|
|
||||||
<a name="new_Waterfall_new"></a> |
|
||||||
|
|
||||||
### new Waterfall() |
|
||||||
<p>Instantiate a new Waterfall.</p> |
|
||||||
|
|
||||||
<a name="Waterfall+guardian"></a> |
|
||||||
|
|
||||||
### waterfall.guardian ⇒ <code>Promise</code> |
|
||||||
<p>Getter that gives a Promise which resolves when all tasks up to when this function is called are done.</p> |
|
||||||
<p>This Promise cannot reject.</p> |
|
||||||
|
|
||||||
**Kind**: instance property of [<code>Waterfall</code>](#Waterfall) |
|
||||||
<a name="Waterfall+waterfall"></a> |
|
||||||
|
|
||||||
### waterfall.waterfall(func) ⇒ [<code>AsyncFunction</code>](#AsyncFunction) |
|
||||||
**Kind**: instance method of [<code>Waterfall</code>](#Waterfall) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- func [<code>AsyncFunction</code>](#AsyncFunction) |
|
||||||
|
|
||||||
<a name="Waterfall+chain"></a> |
|
||||||
|
|
||||||
### waterfall.chain(promise) ⇒ <code>Promise</code> |
|
||||||
<p>Shorthand for chaining a promise to the Waterfall</p> |
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Waterfall</code>](#Waterfall) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- promise <code>Promise</code> |
|
||||||
|
|
@ -1,10 +0,0 @@ |
|||||||
<a name="module_byline"></a> |
|
||||||
|
|
||||||
## byline |
|
||||||
<a name="module_byline.LineStream"></a> |
|
||||||
|
|
||||||
### byline.LineStream |
|
||||||
<p>Fork from [https://github.com/jahewson/node-byline](https://github.com/jahewson/node-byline).</p> |
|
||||||
|
|
||||||
**Kind**: static class of [<code>byline</code>](#module_byline) |
|
||||||
**See**: https://github.com/jahewson/node-byline |
|
@ -1,34 +0,0 @@ |
|||||||
<a name="module_customUtilsBrowser"></a> |
|
||||||
|
|
||||||
## customUtilsBrowser |
|
||||||
<p>Utility functions that need to be reimplemented for each environment. |
|
||||||
This is the version for the browser & React-Native</p> |
|
||||||
|
|
||||||
|
|
||||||
* [customUtilsBrowser](#module_customUtilsBrowser) |
|
||||||
* [~randomBytes(size)](#module_customUtilsBrowser..randomBytes) ⇒ <code>array.<number></code> |
|
||||||
* [~byteArrayToBase64(uint8)](#module_customUtilsBrowser..byteArrayToBase64) ⇒ <code>string</code> |
|
||||||
|
|
||||||
<a name="module_customUtilsBrowser..randomBytes"></a> |
|
||||||
|
|
||||||
### customUtilsBrowser~randomBytes(size) ⇒ <code>array.<number></code> |
|
||||||
<p>Taken from the crypto-browserify module |
|
||||||
https://github.com/dominictarr/crypto-browserify |
|
||||||
NOTE: Math.random() does not guarantee "cryptographic quality" but we actually don't need it</p> |
|
||||||
|
|
||||||
**Kind**: inner method of [<code>customUtilsBrowser</code>](#module_customUtilsBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- size <code>number</code> - <p>in bytes</p> |
|
||||||
|
|
||||||
<a name="module_customUtilsBrowser..byteArrayToBase64"></a> |
|
||||||
|
|
||||||
### customUtilsBrowser~byteArrayToBase64(uint8) ⇒ <code>string</code> |
|
||||||
<p>Taken from the base64-js module |
|
||||||
https://github.com/beatgammit/base64-js/</p> |
|
||||||
|
|
||||||
**Kind**: inner method of [<code>customUtilsBrowser</code>](#module_customUtilsBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- uint8 <code>array</code> |
|
||||||
|
|
@ -1,41 +0,0 @@ |
|||||||
<a name="module_customUtilsNode"></a> |
|
||||||
|
|
||||||
## customUtilsNode |
|
||||||
<p>Utility functions that need to be reimplemented for each environment. |
|
||||||
This is the version for Node.js</p> |
|
||||||
|
|
||||||
|
|
||||||
* [customUtilsNode](#module_customUtilsNode) |
|
||||||
* [.uid(len)](#module_customUtilsNode.uid) ⇒ <code>string</code> |
|
||||||
* [.uid(len)](#module_customUtilsNode.uid) ⇒ <code>string</code> |
|
||||||
|
|
||||||
<a name="module_customUtilsNode.uid"></a> |
|
||||||
|
|
||||||
### customUtilsNode.uid(len) ⇒ <code>string</code> |
|
||||||
<p>Return a random alphanumerical string of length len |
|
||||||
There is a very small probability (less than 1/1,000,000) for the length to be less than len |
|
||||||
(il the base64 conversion yields too many pluses and slashes) but |
|
||||||
that's not an issue here |
|
||||||
The probability of a collision is extremely small (need 3*10^12 documents to have one chance in a million of a collision) |
|
||||||
See http://en.wikipedia.org/wiki/Birthday_problem</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>customUtilsNode</code>](#module_customUtilsNode) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- len <code>number</code> |
|
||||||
|
|
||||||
<a name="module_customUtilsNode.uid"></a> |
|
||||||
|
|
||||||
### customUtilsNode.uid(len) ⇒ <code>string</code> |
|
||||||
<p>Return a random alphanumerical string of length len |
|
||||||
There is a very small probability (less than 1/1,000,000) for the length to be less than len |
|
||||||
(il the base64 conversion yields too many pluses and slashes) but |
|
||||||
that's not an issue here |
|
||||||
The probability of a collision is extremely small (need 3*10^12 documents to have one chance in a million of a collision) |
|
||||||
See http://en.wikipedia.org/wiki/Birthday_problem</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>customUtilsNode</code>](#module_customUtilsNode) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- len <code>number</code> |
|
||||||
|
|
@ -1,155 +0,0 @@ |
|||||||
<a name="NoParamCallback"></a> |
|
||||||
|
|
||||||
## NoParamCallback : <code>function</code> |
|
||||||
<p>Callback with no parameter</p> |
|
||||||
|
|
||||||
**Kind**: global typedef |
|
||||||
**Params** |
|
||||||
|
|
||||||
- err <code>Error</code> |
|
||||||
|
|
||||||
|
|
||||||
<a name="compareStrings"></a> |
|
||||||
|
|
||||||
## compareStrings ⇒ <code>number</code> |
|
||||||
<p>String comparison function.</p> |
|
||||||
<pre class="prettyprint source"><code> if (a < b) return -1 |
|
||||||
if (a > b) return 1 |
|
||||||
return 0 |
|
||||||
</code></pre> |
|
||||||
|
|
||||||
**Kind**: global typedef |
|
||||||
**Params** |
|
||||||
|
|
||||||
- a <code>string</code> |
|
||||||
- b <code>string</code> |
|
||||||
|
|
||||||
|
|
||||||
<a name="MultipleDocumentsCallback"></a> |
|
||||||
|
|
||||||
## MultipleDocumentsCallback : <code>function</code> |
|
||||||
<p>Callback that returns an Array of documents</p> |
|
||||||
|
|
||||||
**Kind**: global typedef |
|
||||||
**Params** |
|
||||||
|
|
||||||
- err <code>Error</code> |
|
||||||
- docs [<code>Array.<document></code>](#document) |
|
||||||
|
|
||||||
|
|
||||||
<a name="SingleDocumentCallback"></a> |
|
||||||
|
|
||||||
## SingleDocumentCallback : <code>function</code> |
|
||||||
<p>Callback that returns a single document</p> |
|
||||||
|
|
||||||
**Kind**: global typedef |
|
||||||
**Params** |
|
||||||
|
|
||||||
- err <code>Error</code> |
|
||||||
- docs [<code>document</code>](#document) |
|
||||||
|
|
||||||
|
|
||||||
<a name="AsyncFunction"></a> |
|
||||||
|
|
||||||
## AsyncFunction ⇒ <code>Promise.<\*></code> |
|
||||||
<p>Generic async function</p> |
|
||||||
|
|
||||||
**Kind**: global typedef |
|
||||||
**Params** |
|
||||||
|
|
||||||
- ...args <code>\*</code> |
|
||||||
|
|
||||||
|
|
||||||
<a name="document"></a> |
|
||||||
|
|
||||||
## document : <code>Object.<string, \*></code> |
|
||||||
<p>Generic document in NeDB. |
|
||||||
It consists of an Object with anything you want inside.</p> |
|
||||||
|
|
||||||
**Kind**: global typedef |
|
||||||
**Properties** |
|
||||||
|
|
||||||
| Name | Type | Description | |
|
||||||
| --- | --- | --- | |
|
||||||
| [_id] | <code>string</code> | <p>Internal <code>_id</code> of the document, which can be <code>null</code> or undefined at some points (when not inserted yet for example).</p> | |
|
||||||
|
|
||||||
|
|
||||||
<a name="query"></a> |
|
||||||
|
|
||||||
## query : <code>Object.<string, \*></code> |
|
||||||
<p>Nedb query.</p> |
|
||||||
<p>Each key of a query references a field name, which can use the dot-notation to reference subfields inside nested |
|
||||||
documents, arrays, arrays of subdocuments and to match a specific element of an array.</p> |
|
||||||
<p>Each value of a query can be one of the following:</p> |
|
||||||
<ul> |
|
||||||
<li><code>string</code>: matches all documents which have this string as value for the referenced field name</li> |
|
||||||
<li><code>number</code>: matches all documents which have this number as value for the referenced field name</li> |
|
||||||
<li><code>Regexp</code>: matches all documents which have a value that matches the given <code>Regexp</code> for the referenced field name</li> |
|
||||||
<li><code>object</code>: matches all documents which have this object as deep-value for the referenced field name</li> |
|
||||||
<li>Comparison operators: the syntax is <code>{ field: { $op: value } }</code> where <code>$op</code> is any comparison operator: |
|
||||||
<ul> |
|
||||||
<li><code>$lt</code>, <code>$lte</code>: less than, less than or equal</li> |
|
||||||
<li><code>$gt</code>, <code>$gte</code>: greater than, greater than or equal</li> |
|
||||||
<li><code>$in</code>: member of. <code>value</code> must be an array of values</li> |
|
||||||
<li><code>$ne</code>, <code>$nin</code>: not equal, not a member of</li> |
|
||||||
<li><code>$stat</code>: checks whether the document posses the property <code>field</code>. <code>value</code> should be true or false</li> |
|
||||||
<li><code>$regex</code>: checks whether a string is matched by the regular expression. Contrary to MongoDB, the use of |
|
||||||
<code>$options</code> with <code>$regex</code> is not supported, because it doesn't give you more power than regex flags. Basic |
|
||||||
queries are more readable so only use the <code>$regex</code> operator when you need to use another operator with it</li> |
|
||||||
<li><code>$size</code>: if the referenced filed is an Array, matches on the size of the array</li> |
|
||||||
<li><code>$elemMatch</code>: matches if at least one array element matches the sub-query entirely</li> |
|
||||||
</ul> |
|
||||||
</li> |
|
||||||
<li>Logical operators: You can combine queries using logical operators: |
|
||||||
<ul> |
|
||||||
<li>For <code>$or</code> and <code>$and</code>, the syntax is <code>{ $op: [query1, query2, ...] }</code>.</li> |
|
||||||
<li>For <code>$not</code>, the syntax is <code>{ $not: query }</code></li> |
|
||||||
<li>For <code>$where</code>, the syntax is:</li> |
|
||||||
</ul> |
|
||||||
<pre class="prettyprint source"><code>{ $where: function () { |
|
||||||
// object is 'this' |
|
||||||
// return a boolean |
|
||||||
} } |
|
||||||
</code></pre> |
|
||||||
</li> |
|
||||||
</ul> |
|
||||||
|
|
||||||
**Kind**: global typedef |
|
||||||
|
|
||||||
<a name="projection"></a> |
|
||||||
|
|
||||||
## projection : <code>Object.<string, (0\|1)></code> |
|
||||||
<p>Nedb projection.</p> |
|
||||||
<p>You can give <code>find</code> and <code>findOne</code> an optional second argument, <code>projections</code>. |
|
||||||
The syntax is the same as MongoDB: <code>{ a: 1, b: 1 }</code> to return only the <code>a</code> |
|
||||||
and <code>b</code> fields, <code>{ a: 0, b: 0 }</code> to omit these two fields. You cannot use both |
|
||||||
modes at the time, except for <code>_id</code> which is by default always returned and |
|
||||||
which you can choose to omit. You can project on nested documents.</p> |
|
||||||
<p>To reference subfields, you can use the dot-notation.</p> |
|
||||||
|
|
||||||
**Kind**: global typedef |
|
||||||
|
|
||||||
<a name="serializationHook"></a> |
|
||||||
|
|
||||||
## serializationHook ⇒ <code>string</code> |
|
||||||
<p>The <code>beforeDeserialization</code>and <code>afterDeserialization</code> callbacks should</p> |
|
||||||
|
|
||||||
**Kind**: global typedef |
|
||||||
**Params** |
|
||||||
|
|
||||||
- x <code>string</code> |
|
||||||
|
|
||||||
|
|
||||||
<a name="rawIndex"></a> |
|
||||||
|
|
||||||
## rawIndex |
|
||||||
**Kind**: global typedef |
|
||||||
**Properties** |
|
||||||
|
|
||||||
| Name | Type | |
|
||||||
| --- | --- | |
|
||||||
| fieldName | <code>string</code> | |
|
||||||
| [unique] | <code>boolean</code> | |
|
||||||
| [sparse] | <code>boolean</code> | |
|
||||||
|
|
||||||
|
|
@ -1,206 +0,0 @@ |
|||||||
<a name="module_model"></a> |
|
||||||
|
|
||||||
## model |
|
||||||
<p>Handle models (i.e. docs) |
|
||||||
Serialization/deserialization |
|
||||||
Copying |
|
||||||
Querying, update</p> |
|
||||||
|
|
||||||
|
|
||||||
* [model](#module_model) |
|
||||||
* _static_ |
|
||||||
* [.checkObject(obj)](#module_model.checkObject) |
|
||||||
* [.serialize(obj)](#module_model.serialize) ⇒ <code>string</code> |
|
||||||
* [.deserialize(rawData)](#module_model.deserialize) ⇒ [<code>document</code>](#document) |
|
||||||
* [.compareThings(a, b, [_compareStrings])](#module_model.compareThings) ⇒ <code>number</code> |
|
||||||
* [.modify(obj, updateQuery)](#module_model.modify) ⇒ [<code>document</code>](#document) |
|
||||||
* [.getDotValue(obj, field)](#module_model.getDotValue) ⇒ <code>\*</code> |
|
||||||
* [.areThingsEqual(a, a)](#module_model.areThingsEqual) ⇒ <code>boolean</code> |
|
||||||
* [.match(obj, query)](#module_model.match) ⇒ <code>boolean</code> |
|
||||||
* _inner_ |
|
||||||
* [~modifierFunctions](#module_model..modifierFunctions) : <code>enum</code> |
|
||||||
* [~comparisonFunctions](#module_model..comparisonFunctions) : <code>enum</code> |
|
||||||
* [~logicalOperators](#module_model..logicalOperators) |
|
||||||
* [~modifierFunction](#module_model..modifierFunction) : <code>function</code> |
|
||||||
* [~comparisonOperator](#module_model..comparisonOperator) ⇒ <code>boolean</code> |
|
||||||
* [~whereCallback](#module_model..whereCallback) ⇒ <code>boolean</code> |
|
||||||
|
|
||||||
<a name="module_model.checkObject"></a> |
|
||||||
|
|
||||||
### model.checkObject(obj) |
|
||||||
<p>Check a DB object and throw an error if it's not valid |
|
||||||
Works by applying the above checkKey function to all fields recursively</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- obj [<code>document</code>](#document) | [<code>Array.<document></code>](#document) |
|
||||||
|
|
||||||
<a name="module_model.serialize"></a> |
|
||||||
|
|
||||||
### model.serialize(obj) ⇒ <code>string</code> |
|
||||||
<p>Serialize an object to be persisted to a one-line string |
|
||||||
For serialization/deserialization, we use the native JSON parser and not eval or Function |
|
||||||
That gives us less freedom but data entered in the database may come from users |
|
||||||
so eval and the like are not safe |
|
||||||
Accepted primitive types: Number, String, Boolean, Date, null |
|
||||||
Accepted secondary types: Objects, Arrays</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- obj [<code>document</code>](#document) |
|
||||||
|
|
||||||
<a name="module_model.deserialize"></a> |
|
||||||
|
|
||||||
### model.deserialize(rawData) ⇒ [<code>document</code>](#document) |
|
||||||
<p>From a one-line representation of an object generate by the serialize function |
|
||||||
Return the object itself</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- rawData <code>string</code> |
|
||||||
|
|
||||||
<a name="module_model.compareThings"></a> |
|
||||||
|
|
||||||
### model.compareThings(a, b, [_compareStrings]) ⇒ <code>number</code> |
|
||||||
<p>Compare { things U undefined } |
|
||||||
Things are defined as any native types (string, number, boolean, null, date) and objects |
|
||||||
We need to compare with undefined as it will be used in indexes |
|
||||||
In the case of objects and arrays, we deep-compare |
|
||||||
If two objects dont have the same type, the (arbitrary) type hierarchy is: undefined, null, number, strings, boolean, dates, arrays, objects |
|
||||||
Return -1 if a < b, 1 if a > b and 0 if a = b (note that equality here is NOT the same as defined in areThingsEqual!)</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- a <code>\*</code> |
|
||||||
- b <code>\*</code> |
|
||||||
- [_compareStrings] [<code>compareStrings</code>](#compareStrings) - <p>String comparing function, returning -1, 0 or 1, overriding default string comparison (useful for languages with accented letters)</p> |
|
||||||
|
|
||||||
<a name="module_model.modify"></a> |
|
||||||
|
|
||||||
### model.modify(obj, updateQuery) ⇒ [<code>document</code>](#document) |
|
||||||
<p>Modify a DB object according to an update query</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- obj [<code>document</code>](#document) |
|
||||||
- updateQuery [<code>query</code>](#query) |
|
||||||
|
|
||||||
<a name="module_model.getDotValue"></a> |
|
||||||
|
|
||||||
### model.getDotValue(obj, field) ⇒ <code>\*</code> |
|
||||||
<p>Get a value from object with dot notation</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- obj <code>object</code> |
|
||||||
- field <code>string</code> |
|
||||||
|
|
||||||
<a name="module_model.areThingsEqual"></a> |
|
||||||
|
|
||||||
### model.areThingsEqual(a, a) ⇒ <code>boolean</code> |
|
||||||
<p>Check whether 'things' are equal |
|
||||||
Things are defined as any native types (string, number, boolean, null, date) and objects |
|
||||||
In the case of object, we check deep equality |
|
||||||
Returns true if they are, false otherwise</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- a <code>\*</code> |
|
||||||
- a <code>\*</code> |
|
||||||
|
|
||||||
<a name="module_model.match"></a> |
|
||||||
|
|
||||||
### model.match(obj, query) ⇒ <code>boolean</code> |
|
||||||
<p>Tell if a given document matches a query</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- obj [<code>document</code>](#document) - <p>Document to check</p> |
|
||||||
- query [<code>query</code>](#query) |
|
||||||
|
|
||||||
<a name="module_model..modifierFunctions"></a> |
|
||||||
|
|
||||||
### model~modifierFunctions : <code>enum</code> |
|
||||||
**Kind**: inner enum of [<code>model</code>](#module_model) |
|
||||||
**Properties** |
|
||||||
|
|
||||||
| Name | Type | Default | Description | |
|
||||||
| --- | --- | --- | --- | |
|
||||||
| $set | <code>modifierFunction</code> | <code></code> | <p>Set a field to a new value</p> | |
|
||||||
| $unset | <code>modifierFunction</code> | <code></code> | <p>Unset a field</p> | |
|
||||||
| $min | <code>modifierFunction</code> | <code></code> | <p>Updates the value of the field, only if specified field is smaller than the current value of the field</p> | |
|
||||||
| $max | <code>modifierFunction</code> | <code></code> | <p>Updates the value of the field, only if specified field is greater than the current value of the field</p> | |
|
||||||
| $inc | <code>modifierFunction</code> | <code></code> | <p>Increment a numeric field's value</p> | |
|
||||||
| $pull | <code>modifierFunction</code> | <code></code> | <p>Removes all instances of a value from an existing array</p> | |
|
||||||
| $pop | <code>modifierFunction</code> | <code></code> | <p>Remove the first or last element of an array</p> | |
|
||||||
| $addToSet | <code>modifierFunction</code> | <code></code> | <p>Add an element to an array field only if it is not already in it No modification if the element is already in the array Note that it doesn't check whether the original array contains duplicates</p> | |
|
||||||
| $push | <code>modifierFunction</code> | <code></code> | <p>Push an element to the end of an array field Optional modifier $each instead of value to push several values Optional modifier $slice to slice the resulting array, see https://docs.mongodb.org/manual/reference/operator/update/slice/ Difference with MongoDB: if $slice is specified and not $each, we act as if value is an empty array</p> | |
|
||||||
|
|
||||||
<a name="module_model..comparisonFunctions"></a> |
|
||||||
|
|
||||||
### model~comparisonFunctions : <code>enum</code> |
|
||||||
**Kind**: inner enum of [<code>model</code>](#module_model) |
|
||||||
**Properties** |
|
||||||
|
|
||||||
| Name | Type | Default | Description | |
|
||||||
| --- | --- | --- | --- | |
|
||||||
| $lt | <code>comparisonOperator</code> | <code></code> | <p>Lower than</p> | |
|
||||||
| $lte | <code>comparisonOperator</code> | <code></code> | <p>Lower than or equals</p> | |
|
||||||
| $gt | <code>comparisonOperator</code> | <code></code> | <p>Greater than</p> | |
|
||||||
| $gte | <code>comparisonOperator</code> | <code></code> | <p>Greater than or equals</p> | |
|
||||||
| $ne | <code>comparisonOperator</code> | <code></code> | <p>Does not equal</p> | |
|
||||||
| $in | <code>comparisonOperator</code> | <code></code> | <p>Is in Array</p> | |
|
||||||
| $nin | <code>comparisonOperator</code> | <code></code> | <p>Is not in Array</p> | |
|
||||||
| $regex | <code>comparisonOperator</code> | <code></code> | <p>Matches Regexp</p> | |
|
||||||
| $exists | <code>comparisonOperator</code> | <code></code> | <p>Returns true if field exists</p> | |
|
||||||
| $size | <code>comparisonOperator</code> | <code></code> | <p>Specific to Arrays, returns true if a length equals b</p> | |
|
||||||
| $elemMatch | <code>comparisonOperator</code> | <code></code> | <p>Specific to Arrays, returns true if some elements of a match the query b</p> | |
|
||||||
|
|
||||||
<a name="module_model..logicalOperators"></a> |
|
||||||
|
|
||||||
### model~logicalOperators |
|
||||||
**Kind**: inner enum of [<code>model</code>](#module_model) |
|
||||||
**Properties** |
|
||||||
|
|
||||||
| Name | Default | Description | |
|
||||||
| --- | --- | --- | |
|
||||||
| $or | <code></code> | <p>Match any of the subqueries</p> | |
|
||||||
| $and | <code></code> | <p>Match all of the subqueries</p> | |
|
||||||
| $not | <code></code> | <p>Inverted match of the query</p> | |
|
||||||
| $where | <code></code> | <p>Use a function to match</p> | |
|
||||||
|
|
||||||
<a name="module_model..modifierFunction"></a> |
|
||||||
|
|
||||||
### model~modifierFunction : <code>function</code> |
|
||||||
**Kind**: inner typedef of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- obj <code>Object</code> - <p>The model to modify</p> |
|
||||||
- field <code>String</code> - <p>Can contain dots, in that case that means we will set a subfield recursively</p> |
|
||||||
- value [<code>document</code>](#document) |
|
||||||
|
|
||||||
<a name="module_model..comparisonOperator"></a> |
|
||||||
|
|
||||||
### model~comparisonOperator ⇒ <code>boolean</code> |
|
||||||
**Kind**: inner typedef of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- a <code>\*</code> - <p>Value in the object</p> |
|
||||||
- b <code>\*</code> - <p>Value in the query</p> |
|
||||||
|
|
||||||
<a name="module_model..whereCallback"></a> |
|
||||||
|
|
||||||
### model~whereCallback ⇒ <code>boolean</code> |
|
||||||
**Kind**: inner typedef of [<code>model</code>](#module_model) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- obj [<code>document</code>](#document) |
|
||||||
|
|
@ -1,360 +0,0 @@ |
|||||||
<a name="module_storage"></a> |
|
||||||
|
|
||||||
## storage |
|
||||||
<p>Way data is stored for this database. |
|
||||||
This version is the Node.js/Node Webkit version. |
|
||||||
It's essentially fs, mkdirp and crash safe write and read functions.</p> |
|
||||||
|
|
||||||
**See** |
|
||||||
|
|
||||||
- module:storageBrowser |
|
||||||
- module:storageReactNative |
|
||||||
|
|
||||||
|
|
||||||
* [storage](#module_storage) |
|
||||||
* _static_ |
|
||||||
* [.exists(file, cb)](#module_storage.exists) |
|
||||||
* [.existsAsync(file)](#module_storage.existsAsync) ⇒ <code>Promise.<boolean></code> |
|
||||||
* [.rename(oldPath, newPath, c)](#module_storage.rename) ⇒ <code>void</code> |
|
||||||
* [.renameAsync(oldPath, newPath)](#module_storage.renameAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.writeFile(path, data, options, callback)](#module_storage.writeFile) |
|
||||||
* [.writeFileAsync(path, data, [options])](#module_storage.writeFileAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.writeFileStream(path, [options])](#module_storage.writeFileStream) ⇒ <code>fs.WriteStream</code> |
|
||||||
* [.unlink(path, callback)](#module_storage.unlink) |
|
||||||
* [.unlinkAsync(path)](#module_storage.unlinkAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.appendFile(path, data, options, callback)](#module_storage.appendFile) |
|
||||||
* [.appendFileAsync(path, data, [options])](#module_storage.appendFileAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.readFile(path, options, callback)](#module_storage.readFile) |
|
||||||
* [.readFileAsync(path, [options])](#module_storage.readFileAsync) ⇒ <code>Promise.<Buffer></code> |
|
||||||
* [.readFileStream(path, [options])](#module_storage.readFileStream) ⇒ <code>fs.ReadStream</code> |
|
||||||
* [.mkdir(path, options, callback)](#module_storage.mkdir) |
|
||||||
* [.mkdirAsync(path, options)](#module_storage.mkdirAsync) ⇒ <code>Promise.<(void\|string)></code> |
|
||||||
* [.ensureFileDoesntExistAsync(file)](#module_storage.ensureFileDoesntExistAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.ensureFileDoesntExist(file, callback)](#module_storage.ensureFileDoesntExist) |
|
||||||
* [.flushToStorage(options, callback)](#module_storage.flushToStorage) |
|
||||||
* [.flushToStorageAsync(options)](#module_storage.flushToStorageAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.writeFileLines(filename, lines, [callback])](#module_storage.writeFileLines) |
|
||||||
* [.writeFileLinesAsync(filename, lines)](#module_storage.writeFileLinesAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.crashSafeWriteFileLines(filename, lines, [callback])](#module_storage.crashSafeWriteFileLines) |
|
||||||
* [.crashSafeWriteFileLinesAsync(filename, lines)](#module_storage.crashSafeWriteFileLinesAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.ensureDatafileIntegrity(filename, callback)](#module_storage.ensureDatafileIntegrity) |
|
||||||
* [.ensureDatafileIntegrityAsync(filename)](#module_storage.ensureDatafileIntegrityAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* _inner_ |
|
||||||
* [~existsCallback](#module_storage..existsCallback) : <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storage.exists"></a> |
|
||||||
|
|
||||||
### storage.exists(file, cb) |
|
||||||
<p>Callback returns true if file exists.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- file <code>string</code> |
|
||||||
- cb [<code>existsCallback</code>](#module_storage..existsCallback) |
|
||||||
|
|
||||||
<a name="module_storage.existsAsync"></a> |
|
||||||
|
|
||||||
### storage.existsAsync(file) ⇒ <code>Promise.<boolean></code> |
|
||||||
<p>Async version of [exists](#module_storage.exists).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.exists |
|
||||||
**Params** |
|
||||||
|
|
||||||
- file <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storage.rename"></a> |
|
||||||
|
|
||||||
### storage.rename(oldPath, newPath, c) ⇒ <code>void</code> |
|
||||||
<p>Node.js' [fs.rename](https://nodejs.org/api/fs.html#fsrenameoldpath-newpath-callback).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- oldPath <code>string</code> |
|
||||||
- newPath <code>string</code> |
|
||||||
- c [<code>NoParamCallback</code>](#NoParamCallback) |
|
||||||
|
|
||||||
<a name="module_storage.renameAsync"></a> |
|
||||||
|
|
||||||
### storage.renameAsync(oldPath, newPath) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [rename](#module_storage.rename).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.rename |
|
||||||
**Params** |
|
||||||
|
|
||||||
- oldPath <code>string</code> |
|
||||||
- newPath <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storage.writeFile"></a> |
|
||||||
|
|
||||||
### storage.writeFile(path, data, options, callback) |
|
||||||
<p>Node.js' [fs.writeFile](https://nodejs.org/api/fs.html#fswritefilefile-data-options-callback).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- data <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storage.writeFileAsync"></a> |
|
||||||
|
|
||||||
### storage.writeFileAsync(path, data, [options]) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [writeFile](#module_storage.writeFile).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.writeFile |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- data <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storage.writeFileStream"></a> |
|
||||||
|
|
||||||
### storage.writeFileStream(path, [options]) ⇒ <code>fs.WriteStream</code> |
|
||||||
<p>Node.js' [fs.createWriteStream](https://nodejs.org/api/fs.html#fscreatewritestreampath-options).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- [options] <code>Object</code> |
|
||||||
|
|
||||||
<a name="module_storage.unlink"></a> |
|
||||||
|
|
||||||
### storage.unlink(path, callback) |
|
||||||
<p>Node.js' [fs.unlink](https://nodejs.org/api/fs.html#fsunlinkpath-callback).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storage.unlinkAsync"></a> |
|
||||||
|
|
||||||
### storage.unlinkAsync(path) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [unlink](#module_storage.unlink).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.unlink |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storage.appendFile"></a> |
|
||||||
|
|
||||||
### storage.appendFile(path, data, options, callback) |
|
||||||
<p>Node.js' [fs.appendFile](https://nodejs.org/api/fs.html#fsappendfilepath-data-options-callback).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- data <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storage.appendFileAsync"></a> |
|
||||||
|
|
||||||
### storage.appendFileAsync(path, data, [options]) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [appendFile](#module_storage.appendFile).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.appendFile |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- data <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storage.readFile"></a> |
|
||||||
|
|
||||||
### storage.readFile(path, options, callback) |
|
||||||
<p>Node.js' [fs.readFile](https://nodejs.org/api/fs.html#fsreadfilepath-options-callback)</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storage.readFileAsync"></a> |
|
||||||
|
|
||||||
### storage.readFileAsync(path, [options]) ⇒ <code>Promise.<Buffer></code> |
|
||||||
<p>Async version of [readFile](#module_storage.readFile).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.readFile |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storage.readFileStream"></a> |
|
||||||
|
|
||||||
### storage.readFileStream(path, [options]) ⇒ <code>fs.ReadStream</code> |
|
||||||
<p>Node.js' [fs.createReadStream](https://nodejs.org/api/fs.html#fscreatereadstreampath-options).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- [options] <code>Object</code> |
|
||||||
|
|
||||||
<a name="module_storage.mkdir"></a> |
|
||||||
|
|
||||||
### storage.mkdir(path, options, callback) |
|
||||||
<p>Node.js' [fs.mkdir](https://nodejs.org/api/fs.html#fsmkdirpath-options-callback).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storage.mkdirAsync"></a> |
|
||||||
|
|
||||||
### storage.mkdirAsync(path, options) ⇒ <code>Promise.<(void\|string)></code> |
|
||||||
<p>Async version of [mkdir](#module_storage.mkdir).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.mkdir |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storage.ensureFileDoesntExistAsync"></a> |
|
||||||
|
|
||||||
### storage.ensureFileDoesntExistAsync(file) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [ensureFileDoesntExist](#module_storage.ensureFileDoesntExist)</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.ensureFileDoesntExist |
|
||||||
**Params** |
|
||||||
|
|
||||||
- file <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storage.ensureFileDoesntExist"></a> |
|
||||||
|
|
||||||
### storage.ensureFileDoesntExist(file, callback) |
|
||||||
<p>Removes file if it exists.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- file <code>string</code> |
|
||||||
- callback [<code>NoParamCallback</code>](#NoParamCallback) |
|
||||||
|
|
||||||
<a name="module_storage.flushToStorage"></a> |
|
||||||
|
|
||||||
### storage.flushToStorage(options, callback) |
|
||||||
<p>Flush data in OS buffer to storage if corresponding option is set.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- options <code>object</code> | <code>string</code> - <p>If options is a string, it is assumed that the flush of the file (not dir) called options was requested</p> |
|
||||||
- [.filename] <code>string</code> |
|
||||||
- [.isDir] <code>boolean</code> <code> = false</code> - <p>Optional, defaults to false</p> |
|
||||||
- callback [<code>NoParamCallback</code>](#NoParamCallback) |
|
||||||
|
|
||||||
<a name="module_storage.flushToStorageAsync"></a> |
|
||||||
|
|
||||||
### storage.flushToStorageAsync(options) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [flushToStorage](#module_storage.flushToStorage).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.flushToStorage |
|
||||||
**Params** |
|
||||||
|
|
||||||
- options <code>object</code> | <code>string</code> |
|
||||||
- [.filename] <code>string</code> |
|
||||||
- [.isDir] <code>boolean</code> <code> = false</code> |
|
||||||
|
|
||||||
<a name="module_storage.writeFileLines"></a> |
|
||||||
|
|
||||||
### storage.writeFileLines(filename, lines, [callback]) |
|
||||||
<p>Fully write or rewrite the datafile.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- lines <code>Array.<string></code> |
|
||||||
- [callback] [<code>NoParamCallback</code>](#NoParamCallback) <code> = () => {}</code> |
|
||||||
|
|
||||||
<a name="module_storage.writeFileLinesAsync"></a> |
|
||||||
|
|
||||||
### storage.writeFileLinesAsync(filename, lines) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [writeFileLines](#module_storage.writeFileLines).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.writeFileLines |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- lines <code>Array.<string></code> |
|
||||||
|
|
||||||
<a name="module_storage.crashSafeWriteFileLines"></a> |
|
||||||
|
|
||||||
### storage.crashSafeWriteFileLines(filename, lines, [callback]) |
|
||||||
<p>Fully write or rewrite the datafile, immune to crashes during the write operation (data will not be lost).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- lines <code>Array.<string></code> |
|
||||||
- [callback] [<code>NoParamCallback</code>](#NoParamCallback) - <p>Optional callback, signature: err</p> |
|
||||||
|
|
||||||
<a name="module_storage.crashSafeWriteFileLinesAsync"></a> |
|
||||||
|
|
||||||
### storage.crashSafeWriteFileLinesAsync(filename, lines) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [crashSafeWriteFileLines](#module_storage.crashSafeWriteFileLines).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.crashSafeWriteFileLines |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- lines <code>Array.<string></code> |
|
||||||
|
|
||||||
<a name="module_storage.ensureDatafileIntegrity"></a> |
|
||||||
|
|
||||||
### storage.ensureDatafileIntegrity(filename, callback) |
|
||||||
<p>Ensure the datafile contains all the data, even if there was a crash during a full file write.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- callback [<code>NoParamCallback</code>](#NoParamCallback) - <p>signature: err</p> |
|
||||||
|
|
||||||
<a name="module_storage.ensureDatafileIntegrityAsync"></a> |
|
||||||
|
|
||||||
### storage.ensureDatafileIntegrityAsync(filename) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [ensureDatafileIntegrity](#module_storage.ensureDatafileIntegrity).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storage</code>](#module_storage) |
|
||||||
**See**: module:storage.ensureDatafileIntegrity |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storage..existsCallback"></a> |
|
||||||
|
|
||||||
### storage~existsCallback : <code>function</code> |
|
||||||
**Kind**: inner typedef of [<code>storage</code>](#module_storage) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- exists <code>boolean</code> |
|
||||||
|
|
@ -1,256 +0,0 @@ |
|||||||
<a name="module_storageBrowser"></a> |
|
||||||
|
|
||||||
## storageBrowser |
|
||||||
<p>Way data is stored for this database</p> |
|
||||||
<p>This version is the browser version and uses [localforage](https://github.com/localForage/localForage) which chooses the best option depending on user browser (IndexedDB then WebSQL then localStorage).</p> |
|
||||||
|
|
||||||
**See** |
|
||||||
|
|
||||||
- module:storage |
|
||||||
- module:storageReactNative |
|
||||||
|
|
||||||
|
|
||||||
* [storageBrowser](#module_storageBrowser) |
|
||||||
* _static_ |
|
||||||
* [.existsAsync(file)](#module_storageBrowser.existsAsync) ⇒ <code>Promise.<boolean></code> |
|
||||||
* [.exists(file, cb)](#module_storageBrowser.exists) |
|
||||||
* [.renameAsync(oldPath, newPath)](#module_storageBrowser.renameAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.rename(oldPath, newPath, c)](#module_storageBrowser.rename) ⇒ <code>void</code> |
|
||||||
* [.writeFileAsync(file, data, [options])](#module_storageBrowser.writeFileAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.writeFile(path, data, options, callback)](#module_storageBrowser.writeFile) |
|
||||||
* [.appendFileAsync(filename, toAppend, [options])](#module_storageBrowser.appendFileAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.appendFile(filename, toAppend, [options], callback)](#module_storageBrowser.appendFile) |
|
||||||
* [.readFileAsync(filename, [options])](#module_storageBrowser.readFileAsync) ⇒ <code>Promise.<Buffer></code> |
|
||||||
* [.readFile(filename, options, callback)](#module_storageBrowser.readFile) |
|
||||||
* [.unlinkAsync(filename)](#module_storageBrowser.unlinkAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.unlink(path, callback)](#module_storageBrowser.unlink) |
|
||||||
* [.mkdirAsync(path, [options])](#module_storageBrowser.mkdirAsync) ⇒ <code>Promise.<(void\|string)></code> |
|
||||||
* [.mkdir(path, options, callback)](#module_storageBrowser.mkdir) |
|
||||||
* [.ensureDatafileIntegrityAsync(filename)](#module_storageBrowser.ensureDatafileIntegrityAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.ensureDatafileIntegrity(filename, callback)](#module_storageBrowser.ensureDatafileIntegrity) |
|
||||||
* [.crashSafeWriteFileLinesAsync(filename, lines)](#module_storageBrowser.crashSafeWriteFileLinesAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.crashSafeWriteFileLines(filename, lines, [callback])](#module_storageBrowser.crashSafeWriteFileLines) |
|
||||||
* _inner_ |
|
||||||
* [~existsCallback](#module_storageBrowser..existsCallback) : <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.existsAsync"></a> |
|
||||||
|
|
||||||
### storageBrowser.existsAsync(file) ⇒ <code>Promise.<boolean></code> |
|
||||||
<p>Returns Promise<true> if file exists.</p> |
|
||||||
<p>Async version of [exists](#module_storageBrowser.exists).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**See**: module:storageBrowser.exists |
|
||||||
**Params** |
|
||||||
|
|
||||||
- file <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.exists"></a> |
|
||||||
|
|
||||||
### storageBrowser.exists(file, cb) |
|
||||||
<p>Callback returns true if file exists.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- file <code>string</code> |
|
||||||
- cb [<code>existsCallback</code>](#module_storageBrowser..existsCallback) |
|
||||||
|
|
||||||
<a name="module_storageBrowser.renameAsync"></a> |
|
||||||
|
|
||||||
### storageBrowser.renameAsync(oldPath, newPath) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [rename](#module_storageBrowser.rename).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**See**: module:storageBrowser.rename |
|
||||||
**Params** |
|
||||||
|
|
||||||
- oldPath <code>string</code> |
|
||||||
- newPath <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.rename"></a> |
|
||||||
|
|
||||||
### storageBrowser.rename(oldPath, newPath, c) ⇒ <code>void</code> |
|
||||||
<p>Moves the item from one path to another</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- oldPath <code>string</code> |
|
||||||
- newPath <code>string</code> |
|
||||||
- c [<code>NoParamCallback</code>](#NoParamCallback) |
|
||||||
|
|
||||||
<a name="module_storageBrowser.writeFileAsync"></a> |
|
||||||
|
|
||||||
### storageBrowser.writeFileAsync(file, data, [options]) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [writeFile](#module_storageBrowser.writeFile).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**See**: module:storageBrowser.writeFile |
|
||||||
**Params** |
|
||||||
|
|
||||||
- file <code>string</code> |
|
||||||
- data <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.writeFile"></a> |
|
||||||
|
|
||||||
### storageBrowser.writeFile(path, data, options, callback) |
|
||||||
<p>Saves the item at given path</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- data <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.appendFileAsync"></a> |
|
||||||
|
|
||||||
### storageBrowser.appendFileAsync(filename, toAppend, [options]) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [appendFile](#module_storageBrowser.appendFile).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**See**: module:storageBrowser.appendFile |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- toAppend <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.appendFile"></a> |
|
||||||
|
|
||||||
### storageBrowser.appendFile(filename, toAppend, [options], callback) |
|
||||||
<p>Append to the item at given path</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- toAppend <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.readFileAsync"></a> |
|
||||||
|
|
||||||
### storageBrowser.readFileAsync(filename, [options]) ⇒ <code>Promise.<Buffer></code> |
|
||||||
<p>Async version of [readFile](#module_storageBrowser.readFile).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**See**: module:storageBrowser.readFile |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.readFile"></a> |
|
||||||
|
|
||||||
### storageBrowser.readFile(filename, options, callback) |
|
||||||
<p>Read data at given path</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.unlinkAsync"></a> |
|
||||||
|
|
||||||
### storageBrowser.unlinkAsync(filename) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [unlink](#module_storageBrowser.unlink).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**See**: module:storageBrowser.unlink |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.unlink"></a> |
|
||||||
|
|
||||||
### storageBrowser.unlink(path, callback) |
|
||||||
<p>Remove the data at given path</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.mkdirAsync"></a> |
|
||||||
|
|
||||||
### storageBrowser.mkdirAsync(path, [options]) ⇒ <code>Promise.<(void\|string)></code> |
|
||||||
<p>Shim for [mkdirAsync](#module_storage.mkdirAsync), nothing to do, no directories will be used on the browser.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.mkdir"></a> |
|
||||||
|
|
||||||
### storageBrowser.mkdir(path, options, callback) |
|
||||||
<p>Shim for [mkdir](#module_storage.mkdir), nothing to do, no directories will be used on the browser.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.ensureDatafileIntegrityAsync"></a> |
|
||||||
|
|
||||||
### storageBrowser.ensureDatafileIntegrityAsync(filename) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Shim for [ensureDatafileIntegrityAsync](#module_storage.ensureDatafileIntegrityAsync), nothing to do, no data corruption possible in the browser.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.ensureDatafileIntegrity"></a> |
|
||||||
|
|
||||||
### storageBrowser.ensureDatafileIntegrity(filename, callback) |
|
||||||
<p>Shim for [ensureDatafileIntegrity](#module_storage.ensureDatafileIntegrity), nothing to do, no data corruption possible in the browser.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- callback [<code>NoParamCallback</code>](#NoParamCallback) - <p>signature: err</p> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.crashSafeWriteFileLinesAsync"></a> |
|
||||||
|
|
||||||
### storageBrowser.crashSafeWriteFileLinesAsync(filename, lines) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [crashSafeWriteFileLines](#module_storageBrowser.crashSafeWriteFileLines).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**See**: module:storageBrowser.crashSafeWriteFileLines |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- lines <code>Array.<string></code> |
|
||||||
|
|
||||||
<a name="module_storageBrowser.crashSafeWriteFileLines"></a> |
|
||||||
|
|
||||||
### storageBrowser.crashSafeWriteFileLines(filename, lines, [callback]) |
|
||||||
<p>Fully write or rewrite the datafile, immune to crashes during the write operation (data will not be lost)</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- lines <code>Array.<string></code> |
|
||||||
- [callback] [<code>NoParamCallback</code>](#NoParamCallback) - <p>Optional callback, signature: err</p> |
|
||||||
|
|
||||||
<a name="module_storageBrowser..existsCallback"></a> |
|
||||||
|
|
||||||
### storageBrowser~existsCallback : <code>function</code> |
|
||||||
**Kind**: inner typedef of [<code>storageBrowser</code>](#module_storageBrowser) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- exists <code>boolean</code> |
|
||||||
|
|
@ -1,255 +0,0 @@ |
|||||||
<a name="module_storageReactNative"></a> |
|
||||||
|
|
||||||
## storageReactNative |
|
||||||
<p>Way data is stored for this database</p> |
|
||||||
<p>This version is the React-Native version and uses [@react-native-async-storage/async-storage](https://github.com/react-native-async-storage/async-storage).</p> |
|
||||||
|
|
||||||
**See** |
|
||||||
|
|
||||||
- module:storageBrowser |
|
||||||
- module:storageReactNative |
|
||||||
|
|
||||||
|
|
||||||
* [storageReactNative](#module_storageReactNative) |
|
||||||
* _static_ |
|
||||||
* [.existsAsync(file)](#module_storageReactNative.existsAsync) ⇒ <code>Promise.<boolean></code> |
|
||||||
* [.exists(file, cb)](#module_storageReactNative.exists) |
|
||||||
* [.renameAsync(oldPath, newPath)](#module_storageReactNative.renameAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.rename(oldPath, newPath, c)](#module_storageReactNative.rename) ⇒ <code>void</code> |
|
||||||
* [.writeFileAsync(file, data, [options])](#module_storageReactNative.writeFileAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.writeFile(path, data, options, callback)](#module_storageReactNative.writeFile) |
|
||||||
* [.appendFileAsync(filename, toAppend, [options])](#module_storageReactNative.appendFileAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.appendFile(filename, toAppend, [options], callback)](#module_storageReactNative.appendFile) |
|
||||||
* [.readFileAsync(filename, [options])](#module_storageReactNative.readFileAsync) ⇒ <code>Promise.<string></code> |
|
||||||
* [.readFile(filename, options, callback)](#module_storageReactNative.readFile) |
|
||||||
* [.unlinkAsync(filename)](#module_storageReactNative.unlinkAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.unlink(path, callback)](#module_storageReactNative.unlink) |
|
||||||
* [.mkdirAsync(dir, [options])](#module_storageReactNative.mkdirAsync) ⇒ <code>Promise.<(void\|string)></code> |
|
||||||
* [.mkdir(path, options, callback)](#module_storageReactNative.mkdir) |
|
||||||
* [.ensureDatafileIntegrityAsync(filename)](#module_storageReactNative.ensureDatafileIntegrityAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.ensureDatafileIntegrity(filename, callback)](#module_storageReactNative.ensureDatafileIntegrity) |
|
||||||
* [.crashSafeWriteFileLinesAsync(filename, lines)](#module_storageReactNative.crashSafeWriteFileLinesAsync) ⇒ <code>Promise.<void></code> |
|
||||||
* [.crashSafeWriteFileLines(filename, lines, [callback])](#module_storageReactNative.crashSafeWriteFileLines) |
|
||||||
* _inner_ |
|
||||||
* [~existsCallback](#module_storageReactNative..existsCallback) : <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.existsAsync"></a> |
|
||||||
|
|
||||||
### storageReactNative.existsAsync(file) ⇒ <code>Promise.<boolean></code> |
|
||||||
<p>Async version of [exists](#module_storageReactNative.exists).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**See**: module:storageReactNative.exists |
|
||||||
**Params** |
|
||||||
|
|
||||||
- file <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.exists"></a> |
|
||||||
|
|
||||||
### storageReactNative.exists(file, cb) |
|
||||||
<p>Callback returns true if file exists</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- file <code>string</code> |
|
||||||
- cb [<code>existsCallback</code>](#module_storageReactNative..existsCallback) |
|
||||||
|
|
||||||
<a name="module_storageReactNative.renameAsync"></a> |
|
||||||
|
|
||||||
### storageReactNative.renameAsync(oldPath, newPath) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [rename](#module_storageReactNative.rename).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**See**: module:storageReactNative.rename |
|
||||||
**Params** |
|
||||||
|
|
||||||
- oldPath <code>string</code> |
|
||||||
- newPath <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.rename"></a> |
|
||||||
|
|
||||||
### storageReactNative.rename(oldPath, newPath, c) ⇒ <code>void</code> |
|
||||||
<p>Moves the item from one path to another</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- oldPath <code>string</code> |
|
||||||
- newPath <code>string</code> |
|
||||||
- c [<code>NoParamCallback</code>](#NoParamCallback) |
|
||||||
|
|
||||||
<a name="module_storageReactNative.writeFileAsync"></a> |
|
||||||
|
|
||||||
### storageReactNative.writeFileAsync(file, data, [options]) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [writeFile](#module_storageReactNative.writeFile).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**See**: module:storageReactNative.writeFile |
|
||||||
**Params** |
|
||||||
|
|
||||||
- file <code>string</code> |
|
||||||
- data <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.writeFile"></a> |
|
||||||
|
|
||||||
### storageReactNative.writeFile(path, data, options, callback) |
|
||||||
<p>Saves the item at given path</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- data <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.appendFileAsync"></a> |
|
||||||
|
|
||||||
### storageReactNative.appendFileAsync(filename, toAppend, [options]) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [appendFile](#module_storageReactNative.appendFile).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**See**: module:storageReactNative.appendFile |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- toAppend <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.appendFile"></a> |
|
||||||
|
|
||||||
### storageReactNative.appendFile(filename, toAppend, [options], callback) |
|
||||||
<p>Append to the item at given path</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- toAppend <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.readFileAsync"></a> |
|
||||||
|
|
||||||
### storageReactNative.readFileAsync(filename, [options]) ⇒ <code>Promise.<string></code> |
|
||||||
<p>Async version of [readFile](#module_storageReactNative.readFile).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**See**: module:storageReactNative.readFile |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.readFile"></a> |
|
||||||
|
|
||||||
### storageReactNative.readFile(filename, options, callback) |
|
||||||
<p>Read data at given path</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.unlinkAsync"></a> |
|
||||||
|
|
||||||
### storageReactNative.unlinkAsync(filename) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [unlink](#module_storageReactNative.unlink).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**See**: module:storageReactNative.unlink |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.unlink"></a> |
|
||||||
|
|
||||||
### storageReactNative.unlink(path, callback) |
|
||||||
<p>Remove the data at given path</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.mkdirAsync"></a> |
|
||||||
|
|
||||||
### storageReactNative.mkdirAsync(dir, [options]) ⇒ <code>Promise.<(void\|string)></code> |
|
||||||
<p>Shim for [mkdirAsync](#module_storage.mkdirAsync), nothing to do, no directories will be used on the browser.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- dir <code>string</code> |
|
||||||
- [options] <code>object</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.mkdir"></a> |
|
||||||
|
|
||||||
### storageReactNative.mkdir(path, options, callback) |
|
||||||
<p>Shim for [mkdir](#module_storage.mkdir), nothing to do, no directories will be used on the browser.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- path <code>string</code> |
|
||||||
- options <code>object</code> |
|
||||||
- callback <code>function</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.ensureDatafileIntegrityAsync"></a> |
|
||||||
|
|
||||||
### storageReactNative.ensureDatafileIntegrityAsync(filename) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Shim for [ensureDatafileIntegrityAsync](#module_storage.ensureDatafileIntegrityAsync), nothing to do, no data corruption possible in the browser.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.ensureDatafileIntegrity"></a> |
|
||||||
|
|
||||||
### storageReactNative.ensureDatafileIntegrity(filename, callback) |
|
||||||
<p>Shim for [ensureDatafileIntegrity](#module_storage.ensureDatafileIntegrity), nothing to do, no data corruption possible in the browser.</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- callback [<code>NoParamCallback</code>](#NoParamCallback) - <p>signature: err</p> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.crashSafeWriteFileLinesAsync"></a> |
|
||||||
|
|
||||||
### storageReactNative.crashSafeWriteFileLinesAsync(filename, lines) ⇒ <code>Promise.<void></code> |
|
||||||
<p>Async version of [crashSafeWriteFileLines](#module_storageReactNative.crashSafeWriteFileLines).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**See**: module:storageReactNative.crashSafeWriteFileLines |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- lines <code>Array.<string></code> |
|
||||||
|
|
||||||
<a name="module_storageReactNative.crashSafeWriteFileLines"></a> |
|
||||||
|
|
||||||
### storageReactNative.crashSafeWriteFileLines(filename, lines, [callback]) |
|
||||||
<p>Fully write or rewrite the datafile, immune to crashes during the write operation (data will not be lost)</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- filename <code>string</code> |
|
||||||
- lines <code>Array.<string></code> |
|
||||||
- [callback] [<code>NoParamCallback</code>](#NoParamCallback) - <p>Optional callback, signature: err</p> |
|
||||||
|
|
||||||
<a name="module_storageReactNative..existsCallback"></a> |
|
||||||
|
|
||||||
### storageReactNative~existsCallback : <code>function</code> |
|
||||||
**Kind**: inner typedef of [<code>storageReactNative</code>](#module_storageReactNative) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- exists <code>boolean</code> |
|
||||||
|
|
@ -1,64 +0,0 @@ |
|||||||
<a name="module_utils"></a> |
|
||||||
|
|
||||||
## utils |
|
||||||
<p>Utility functions for all environments. |
|
||||||
This replaces the underscore dependency.</p> |
|
||||||
|
|
||||||
|
|
||||||
* [utils](#module_utils) |
|
||||||
* _static_ |
|
||||||
* [.uniq(array, [iteratee])](#module_utils.uniq) ⇒ <code>Array</code> |
|
||||||
* [.isDate(d)](#module_utils.isDate) ⇒ <code>boolean</code> |
|
||||||
* [.isRegExp(re)](#module_utils.isRegExp) ⇒ <code>boolean</code> |
|
||||||
* _inner_ |
|
||||||
* [~isObject(arg)](#module_utils..isObject) ⇒ <code>boolean</code> |
|
||||||
|
|
||||||
<a name="module_utils.uniq"></a> |
|
||||||
|
|
||||||
### utils.uniq(array, [iteratee]) ⇒ <code>Array</code> |
|
||||||
<p>Produces a duplicate-free version of the array, using === to test object equality. In particular only the first |
|
||||||
occurrence of each value is kept. If you want to compute unique items based on a transformation, pass an iteratee |
|
||||||
function.</p> |
|
||||||
<p>Heavily inspired by [https://underscorejs.org/#uniq](https://underscorejs.org/#uniq).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>utils</code>](#module_utils) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- array <code>Array</code> |
|
||||||
- [iteratee] <code>function</code> - <p>transformation applied to every element before checking for duplicates. This will not |
|
||||||
transform the items in the result.</p> |
|
||||||
|
|
||||||
<a name="module_utils.isDate"></a> |
|
||||||
|
|
||||||
### utils.isDate(d) ⇒ <code>boolean</code> |
|
||||||
<p>Returns true if d is a Date.</p> |
|
||||||
<p>Heavily inspired by [https://underscorejs.org/#isDate](https://underscorejs.org/#isDate).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>utils</code>](#module_utils) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- d <code>\*</code> |
|
||||||
|
|
||||||
<a name="module_utils.isRegExp"></a> |
|
||||||
|
|
||||||
### utils.isRegExp(re) ⇒ <code>boolean</code> |
|
||||||
<p>Returns true if re is a RegExp.</p> |
|
||||||
<p>Heavily inspired by [https://underscorejs.org/#isRegExp](https://underscorejs.org/#isRegExp).</p> |
|
||||||
|
|
||||||
**Kind**: static method of [<code>utils</code>](#module_utils) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- re <code>\*</code> |
|
||||||
|
|
||||||
<a name="module_utils..isObject"></a> |
|
||||||
|
|
||||||
### utils~isObject(arg) ⇒ <code>boolean</code> |
|
||||||
<p>Returns true if arg is an Object. Note that JavaScript arrays and functions are objects, while (normal) strings |
|
||||||
and numbers are not.</p> |
|
||||||
<p>Heavily inspired by [https://underscorejs.org/#isObject](https://underscorejs.org/#isObject).</p> |
|
||||||
|
|
||||||
**Kind**: inner method of [<code>utils</code>](#module_utils) |
|
||||||
**Params** |
|
||||||
|
|
||||||
- arg <code>\*</code> |
|
||||||
|
|
@ -1,67 +0,0 @@ |
|||||||
'use strict' |
|
||||||
const jsdoc2md = require('jsdoc-to-markdown') |
|
||||||
const fs = require('fs') |
|
||||||
const path = require('path') |
|
||||||
|
|
||||||
const jsdocConf = './jsdoc.conf.js' |
|
||||||
|
|
||||||
/* output path */ |
|
||||||
const outputDir = './docs' |
|
||||||
|
|
||||||
const getJsdocDataOptions = { |
|
||||||
/* same input path as jsdoc */ |
|
||||||
files: require(jsdocConf).source.include, |
|
||||||
configure: jsdocConf, |
|
||||||
'no-cache': true |
|
||||||
} |
|
||||||
|
|
||||||
const renderOptions = { |
|
||||||
'param-list-format': 'list' |
|
||||||
} |
|
||||||
|
|
||||||
fs.rmdirSync(outputDir, { recursive: true }) // clean docs dir
|
|
||||||
fs.mkdirSync(outputDir) // make docs dir
|
|
||||||
|
|
||||||
/* get template data */ |
|
||||||
const templateData = jsdoc2md.getTemplateDataSync(getJsdocDataOptions) |
|
||||||
|
|
||||||
/* reduce templateData to an array of class names */ |
|
||||||
const classNames = templateData |
|
||||||
.filter(({ kind, access }) => kind === 'class' && access !== 'private') |
|
||||||
.map(({ name }) => name) |
|
||||||
.filter(name => name !== 'LineStream') // it is a module that exports a class, dirty hack to hardcode this, but it works
|
|
||||||
|
|
||||||
const moduleNames = templateData |
|
||||||
.filter(({ kind, access }) => kind === 'module' && access !== 'private') |
|
||||||
.map(({ name }) => name) |
|
||||||
|
|
||||||
const rest = templateData |
|
||||||
.filter(({ name }) => !moduleNames.includes(name) && !classNames.includes(name)) |
|
||||||
.filter(({ scope, access }) => scope === 'global' && access !== 'private') |
|
||||||
.map(({ id }) => id) |
|
||||||
|
|
||||||
/* create a documentation file for each class */ |
|
||||||
for (const className of classNames) { |
|
||||||
const template = `{{#class name="${className}"}}{{>docs}}{{/class}}` |
|
||||||
console.log(`rendering ${className}, template: ${template}`) |
|
||||||
const output = jsdoc2md.renderSync({ ...renderOptions, data: templateData, template: template }) |
|
||||||
fs.writeFileSync(path.resolve(outputDir, `${className}.md`), output) |
|
||||||
} |
|
||||||
|
|
||||||
/* create a documentation file for each module */ |
|
||||||
for (const moduleName of moduleNames) { |
|
||||||
const template = `{{#module name="${moduleName}"}}{{>docs}}{{/module}}` |
|
||||||
console.log(`rendering ${moduleName}, template: ${template}`) |
|
||||||
const output = jsdoc2md.renderSync({ ...renderOptions, data: templateData, template: template }) |
|
||||||
fs.writeFileSync(path.resolve(outputDir, `${moduleName}.md`), output) |
|
||||||
} |
|
||||||
|
|
||||||
let template = '' |
|
||||||
for (const id of rest) { |
|
||||||
template += `{{#identifier name="${id}"}}{{>docs}}{{/identifier}}\n` |
|
||||||
} |
|
||||||
console.log(`rendering globals, template: ${template}`) |
|
||||||
const output = jsdoc2md.renderSync({ ...renderOptions, data: templateData, template: template }) |
|
||||||
fs.writeFileSync(path.resolve(outputDir, 'globals.md'), output) |
|
||||||
|
|
||||||
// TODO rewrite links between files
|
|
Loading…
Reference in new issue