Determines whether or not the callbacks associated with each event should happen in an async fashion or not. Default is false, which means events are synchronous
A map, with each property being an array of callbacks.
Adds a collection to the database.
name of collection to add
a reference to the collection which was just added
Alias of EventEmitter.on().
(Changes API) : clears all the changes in all collections.
Emits the close event. In autosave scenarios, if the database is dirty, this will save and disable timer. Does not actually destroy the db.
a Promise that resolves after closing the database succeeded
Copies 'this' database into a new Loki instance. Object references are shared to make lightweight.
options
Handles deleting a database from the underlying storage adapter
a Promise that resolves after the database is deleted
Collection level utility function to deserializes a destructured collection.
destructured representation of collection to inflate
used to describe format of destructuredSource input
an array of documents to attach to collection.data.
Database level destructured JSON deserialization routine to minimize memory overhead. Internally, Loki supports destructuring via loki "serializationMethod' option and the optional LokiPartitioningAdapter class. It is also available if you wish to do your own structured persistence or data exchange.
destructured json or array to deserialize from
source format options
An object representation of the deserialized database, not yet applied to 'this' db or document array
Emits a particular event with the option of passing optional parameters which are going to be processed by the callback provided signatures match (i.e. if passing emit(event, arg0, arg1) the listener should take two parameters)
the name of the event
optional object passed with the event
(Changes API) : takes all the changes stored in each collection and creates a single array for the entire database. If an array of names of collections is passed then only the included collections will be tracked.
array of changes
Retrieves reference to a collection by name.
name of collection to look up
Reference to collection in database by that name, or null if not found
configures options related to database persistence.
a Promise that resolves after initialization and (if enabled) autoloading the database
Handles manually loading from an adapter storage (such as fs-storage) This method utilizes loki configuration options (if provided) to determine which persistence method to use, or environment detection (if configuration was not provided). To avoid contention with any throttledSaves, we will drain the save queue first.
If you are configured with autosave, you do not need to call this method yourself.
a Promise that resolves after the database is loaded
Inflates a loki database from a serialized JSON string
a serialized loki database string
apply or override collection level settings
Inflates a loki database from a JS object
a serialized loki database object
apply or override collection level settings
Adds a listener to the queue of callbacks associated to an event
the name(s) of the event(s) to listen to
callback function of listener to attach
the index of the callback in the array of listeners for a particular event
Removes a collection from the database.
name of collection to remove
Removes the listener at position 'index' from the event 'eventName'
the name(s) of the event(s) which the listener is attached to
the listener callback function to remove from emitter
Renames an existing loki collection
name of collection to rename
new name of collection
reference to the newly renamed collection
Handles manually saving to an adapter storage (such as fs-storage) This method utilizes loki configuration options (if provided) to determine which persistence method to use, or environment detection (if configuration was not provided).
If you are configured with autosave, you do not need to call this method yourself.
a Promise that resolves after the database is persisted
Serialize database to a string which can be loaded via {@link Loki#loadJSON}
Stringified representation of the loki database.
(Changes API) - stringify changes for network transmission
string representation of the changes
Collection level utility method to serialize a collection in a 'destructured' format
used to determine output of method
A custom, restructured aggregation of independent serializations for a single collection.
Database level destructured JSON serialization routine to allow alternate serialization methods. Internally, Loki supports destructuring via loki "serializationMethod' option and the optional LokiPartitioningAdapter class. It is also available if you wish to do your own structured persistence or data exchange.
output format options for use externally to loki
A custom, restructured aggregation of independent serializations.
Wait for throttledSaves to complete and invoke your callback when drained or duration is met.
configuration options
a Promise that resolves when save queue is drained, it is passed a sucess parameter value
Generated using TypeDoc
Constructs the main database class.