Optional
options: Partial<DynamicViewOptions>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
applyFilter() - Adds or updates a filter in the DynamicView filter pipeline
this DynamicView object, for further chain ops.
DynamicView
A filter object to add to the pipeline. The object is in the format { 'type': filter_type, 'val', filter_param, 'uid', optional_filter_id }
applyFind() - Adds or updates a mongo-style query option in the DynamicView filter pipeline
this DynamicView object, for further chain ops.
DynamicView
A mongo-style query object to apply to pipeline
Optional
uid: string | numberOptional: The unique ID of this filter, to reference it in the future.
applySimpleSort() - Used to specify a property used for view translation.
dv.applySimpleSort("name");
this DynamicView object, for further chain ops.
DynamicView
Name of property by which to sort.
Optional
options: Partial<{ boolean for sort descending or options object
applySort() - Used to apply a sort to the dynamic view
dv.applySort(function(obj1, obj2) {
if (obj1.name === obj2.name) return 0;
if (obj1.name > obj2.name) return 1;
if (obj1.name < obj2.name) return -1;
});
this DynamicView object, for further chain ops.
DynamicView
a javascript compare function used for sorting
applySortCriteria() - Allows sorting a resultset based on multiple columns.
// to sort by age and then name (both ascending)
dv.applySortCriteria(['age', 'name']);
// to sort by age (ascending) and then by name (descending)
dv.applySortCriteria(['age', ['name', true]);
// to sort by age (descending) and then by name (descending)
dv.applySortCriteria(['age', true], ['name', true]);
Reference to this DynamicView, sorted, for future chain operations.
DynamicView
applyWhere() - Adds or updates a javascript filter function in the DynamicView filter pipeline
this DynamicView object, for further chain ops.
DynamicView
A javascript filter function to apply to pipeline
Optional
uid: string | numberOptional: The unique ID of this filter, to reference it in the future.
branchResultset() - Makes a copy of the internal resultset for branched queries. Unlike this dynamic view, the branched resultset will not be 'live' updated, so your branched query should be immediately resolved and not held for future evaluation.
A copy of the internal resultset for branched queries.
DynamicView
var db = new loki('test');
var coll = db.addCollection('mydocs');
var dv = coll.addDynamicView('myview');
var tx = [
{
type: 'offset',
value: '[%lktxp]pageStart'
},
{
type: 'limit',
value: '[%lktxp]pageSize'
}
];
coll.addTransform('viewPaging', tx);
// add some records
var results = dv.branchResultset('viewPaging', { pageStart: 10, pageSize: 10 }).data();
Optional
transform: string | []Optional name of collection transform, or an array of transform steps
Optional
parameters: Record<string, any>optional parameters (if optional transform requires them)
commit() - commits a transaction.
this DynamicView object, for further chain ops.
data() - resolves and pending filtering and sorting, then returns document array as result.
An array of documents representing the current DynamicView contents.
DynamicView
Optional
options: objectoptional parameters to pass to resultset.data() if non-persistent
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: anyevaluateDocument() - internal method for (re)evaluating document inclusion. Called by : collection.insert() and collection.update().
index of document to (re)run through filter pipeline.
true if the document was just added to the collection.
getSort() - used to get the current sort
function (sortFunction) or array (sortCriteria) or object (sortCriteriaSimple)
mapReduce() - data transformation via user supplied functions
The output of your reduceFunction
DynamicView
this function accepts a single document for you to transform and return
this function accepts many (array of map outputs) and returns single value
on(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
reapplyFilters() - Reapply all the filters in the current pipeline.
this DynamicView object, for further chain ops.
rematerialize() - internally used immediately after deserialization (loading) This will clear out and reapply filterPipeline ops, recreating the view. Since where filters do not persist correctly, this method allows restoring the view to state where user can re-apply those where filters.
This dynamic view for further chained ops.
DynamicView
DynamicView.rebuild
(Optional) allows specification of 'removeWhereFilters' option
removeFilter() - Remove the specified filter from the DynamicView filter pipeline
this DynamicView object, for further chain ops.
DynamicView
The unique ID of the filter to be removed.
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[]rollback() - rolls back a transaction.
this DynamicView object, for further chain ops.
startTransaction() - marks the beginning of a transaction.
this DynamicView object, for further chain ops.
toJSON() - Override of toJSON to avoid circular references
Generated using TypeDoc
LokiEventEmitter is a minimalist version of EventEmitter. It enables any constructor that inherits EventEmitter to emit events and trigger listeners that have been added to the event through the on(event, callback) method