-
Notifications
You must be signed in to change notification settings - Fork 481
Constructor Options
Clemens Damke edited this page Oct 7, 2015
·
2 revisions
-
autosave
: whether or not to make Loki periodically save data (bool) -
autosaveInterval
: the interval in milliseconds for a periodic save -
autoload
: load a db automatically from a file or localstorage/ indexedDB (bool) -
autoloadCallback
: callback after load (function) -
autosaveCallback
: callback after autosave (function) -
persistenceMethod
: the persistence method ('adapter'|null) -
persistenceAdapter
: the instance of a persistence adapter used for saving data
For more information on persistence go here
Collections now take a name parameter and an options object. The possible parameters in the options are:
-
indices
: array of fields to be indexed -
transactional
: is the collection transactional (a fallback mechanism in case things go wrong during operations) -
asyncListeners
: event listeners can be made sync or async -
disableChangesApi
: enable/disable the Changes API wiki page -
cloneObjects
: you can force LokiJS to create clone copies of objects instead of using the original objects -
autoupdate
: enable/disable the autoupdate feature, default =false
(bool)
By default, when you insert and object into a LokiJS database, it refers to your object reference rather than create its own copy. If you prefer LokiJS clone its own copies you can specify collection level clone option.
(need to move below text to another page, perhaps an 'function reference' page)
For chained multisort, some examples include :
rs.compoundsort(['age', 'name']); // to sort by age and then name (both ascending)
rs.compoundsort(['age', ['name', true]); // to sort by age (ascending) and then by name (descending)
For DynamicView view, some examples include :
dv.applySortCriteria(['age', 'name']); // to sort by age and then name (both ascending)
dv.applySortCriteria(['age', ['name', true]); // to sort by age (ascending) and then by name (descending)
dv.applySortCriteria(['age', true], ['name', true]); // to sort by age (descending) and then by name (descending)