Module collection
Provides constructors for standard and partitioned collections.
Class Collection
Instance Methods
- all()
- every(callback, context)
- filter(callback, context)
- forEach(callback, context)
- get(idx)
- indexOf(storable)
- map(callback, context)
- some(callback, context)
Instance Properties
Static Methods
- createInstance(store, collectionMapping, parent)
Class PartitionedCollection
Instance Properties
Collection (store, collectionMapping, selector, parent)
Creates a new Collection instance
Parameters
Store | store | The store to operate on |
Mapping | collectionMapping | The collection mapping |
Object | selector | An object containing the query ast and the sql creation function |
Storable | parent | The parent storable |
Returns
A newly created Collection instance |
Collection.createInstance (store, collectionMapping, parent)
Static factory method for creating new collections
Parameters
Store | store | The store |
CollectionMapping | collectionMapping | The mapping definition of the collection |
Storable | parent | The parent storable |
Returns
Collection | A new Collection instance |
Collection.prototype.all ()
Converts this collection into a plain JavaScript Array
Returns
Array | An array containing the storables of this collection |
Collection.prototype.entity
The name of the storable entity this collection contains
Collection.prototype.every (callback, context)
Executes the provided callback once for each storable in the collection,
until it finds one where the callback function returns false. Similar
to Array.prototype.every()
.
Parameters
Function | callback | The callback to execute |
Object | context | Optional context object, representing the `this`. |
Returns
Boolean | False if a callback execution returned false, true if all callback executions returned true. |
Collection.prototype.filter (callback, context)
Returns an array containing those storables for which the provided callback
function returned true. Similar to Array.prototype.filter()
.
Parameters
Function | callback | The callback to execute |
Object | context | Optional context object, representing the `this`. |
Returns
Array | An array containing storables |
Collection.prototype.forEach (callback, context)
Iterates over the collection, executing the callback method for every
storable found. Similar to Array.prototype.forEach()
.
Parameters
Function | callback | The callback to execute |
Object | context | Optional context object, representing the `this`. |
Collection.prototype.get (idx)
Returns the storable instance at the given index position
Parameters
Number | idx | The index position of the storable to return |
Returns
Storable | The storable at the given index position, or null |
Collection.prototype.ids
An array containing the storable IDs of this collection
Collection.prototype.indexOf (storable)
Returns the index position of the storable passed as argument within the collection.
Parameters
Storable | storable | The storable to get the index position for |
Returns
Number | The index position of the storable |
Collection.prototype.invalidate
Marks the collection as invalid, forcing a reload on next access. Note that when calling this method in an open transaction any pending changes affecting the collection will be visible to other threads only after successfully committing the transaction.
Collection.prototype.length
The size of the collection
Collection.prototype.map (callback, context)
Executes the provided callback for every storable in this collection and
returns an array containing the result values. Similar to Array.prototype.map()
.
Parameters
Function | callback | The callback to execute |
Object | context | Optional context object, representing the `this`. |
Returns
Array | An array containing the result values of the callback executions. |
Collection.prototype.name
The name of the collection
Collection.prototype.some (callback, context)
Executes the provided callback once for each storable in the collection,
until it finds one where the callback returned true. If found this method
immediately returns true, otherwise false. Similar to Array.prototype.some()
.
Parameters
Function | callback | The callback to execute |
Object | context | Optional context object, representing the `this`. |
Returns
Boolean | True if a callback execution returned true, false otherwise. |
Collection.prototype.storables
An array containing the storables of this collection
PartitionedCollection (store, collectionMapping, selector, parent)
Creates a new PartitionedCollection instance
Parameters
Store | store | The store to operate on |
Mapping | collectionMapping | The collection mapping |
Object | selector | An object containing the query ast and the sql creation function |
Storable | parent | The parent storable |
Returns
A newly created PartitionedCollection instance |
See
PartitionedCollection.prototype.ids
An array containing the storable IDs of this collection
PartitionedCollection.prototype.partitions
An array containing the storable partitions of this collection
PartitionedCollection.prototype.storables
An array containing the storable partitions of this collection