Create a instance of the SylvieJS database.
Optional
filename: stringname of the file to be saved to
Optional
options: Partial<ConfigOptions & ConstructorOptions>(Optional) config options object
Alias of LokiEventEmitter.prototype.on addListener(eventName, listener) - adds a listener to the queue of callbacks associated to an event
the index of the callback in the array of listeners for a particular event
LokiEventEmitter
the name(s) of the event(s) to listen to
callback function of listener to attach
boolean 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
LokiEventEmitter
a hashmap, with each property being an array of callbacks
LokiEventEmitter
Optional
optionsOptional
options: Partial<ConfigOptions>Static
CollectionStatic
ComparatorsStatic
DynamicStatic
KeyStatic
LokiStatic
LokiStatic
LokiStatic
LokiStatic
LokiOptional
options: Partial<PartitioningAdapterOptions>Static
ResultsetStatic
aeqStatic
deepStatic
freezeStatic
gtStatic
ltStatic
persistenceStatic
unAdds a collection to the database.
a reference to the collection which was just added
name of collection to add
Optional
options: Record<string, any>(optional) options to configure collection with.
autosaveEnable - begin a javascript interval to periodically save the database.
Optional
options: Record<string, any>not currently used (remove or allow overrides?)
Optional
callback: (() => any)(Optional) user supplied async callback
Copies 'this' database into a new Loki instance. Object references are shared to make lightweight.
Optional
options: { apply or override collection level settings
Optional
removenulls properties not safe for serialization.
Handles deleting a database from file system, local storage, or adapter (indexeddb) This method utilizes loki configuration options (if provided) to determine which persistence method to use, or environment detection (if configuration was not provided).
Sylvie
Optional
callback: ((_: Error | { (Optional) user supplied async callback / error handler
Collection level utility function to deserializes a destructured collection.
an array of documents to attach to collection.data.
destructured representation of collection to inflate
Optional
options: Partial<{ used to describe format of destructuredSource input
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.
An object representation of the deserialized database, not yet applied to 'this' db or document array
destructured json or array to deserialize from
Optional
options: Partial<SerializationOptions>source format options
emit(eventName, data) - 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)
LokiEventEmitter
the name of the event
Optional
data: unknownoptional object passed with the event
Optional
arg: any(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
private method createChange() in Collection
Optional
arrayOfCollectionNames: string | string[]Retrieves reference to a collection by name.
Reference to collection in database by that name, or null if not found
name of collection to look up
Handles manually loading from file system, local storage, or adapter (such as indexeddb) 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.
db.loadDatabase({}, function(err) {
if (err) {
console.log("error : " + err);
}
else {
console.log("database loaded.");
}
});
Optional
options: { if throttling saves and loads, this controls how we drain save queue before loading
Optional
recursive(default: true) wait recursively until no saves are queued
Optional
recursive(default: false) limit our recursive waiting to a duration
Optional
recursive(default: 2000) cutoff in ms to stop recursively re-draining
Optional
callback: ((_: Error | { (Optional) user supplied async callback / error handler. Note on success, the callback param will be null or { success: true }, on error it will be typeof Error or { success: false, error: Error }
Optional
options: { Optional
recursiveOptional
recursiveOptional
recursiveInternal load logic, decoupled from throttling/contention logic
not currently used (remove or allow overrides?)
Optional
callback: ((_: Error | { (Optional) user supplied async callback / error handler
Inflates a loki database from a serialized JSON string
a serialized loki database string
Optional
options: Partial<ChangeOpsLoadJSONOptions>apply or override collection level settings
Inflates a loki database from a JS object
a serialized loki database string
Optional
options: { apply or override collection level settings
Optional
retainwhether collection dirty flags will be preserved
Optional
throttledon(eventName, listener) - adds a listener to the queue of callbacks associated to an event
the index of the callback in the array of listeners for a particular event
LokiEventEmitter
the name(s) of the event(s) to listen to
callback function of listener to attach
removeListener() - removes the listener at position 'index' from the event 'eventName'
LokiEventEmitter
the name(s) of the event(s) which the listener is attached to
the listener callback function to remove from emitter
Rest
...args: any[]Renames an existing loki collection
reference to the newly renamed collection
name of collection to rename
new name of collection
Handles manually saving to file system, local storage, or adapter (such as indexeddb) 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.
Sylvie
db.saveDatabase(function(err) {
if (err) {
console.log("error : " + err);
}
else {
console.log("database saved.");
}
});
Optional
callback: ((_: Error | ResultType) => void)(Optional) user supplied async callback / error handler
Internal save logic, decoupled from save throttling logic
Serialize database to a string which can be loaded via Sylvie#loadJSON
Stringified representation of the loki database.
Collection level utility method to serialize a collection in a 'destructured' format
A custom, restructured aggregation of independent serializations for a single collection.
used to determine output of method
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.
A custom, restructured aggregation of independent serializations.
Optional
options: Partial<SerializationOptions>output format options for use externally to loki
Wait for throttledSaves to complete and invoke your callback when drained or duration is met.
callback to fire when save queue is drained, it is passed a sucess parameter value
Optional
options: { configuration options
Optional
recursive(default: true) if after queue is drained, another save was kicked off, wait for it
Optional
recursive(default: false) limit our recursive waiting to a duration
Optional
recursive(default: 2000) cutoff in ms to stop recursively re-draining
Optional
recursiveOptional
started?: numberGenerated using TypeDoc
Sylvie: The main database class
Implements
SylvieEventEmitter