Decorating observer if not present in prototype chain
Creating store
Constructor
DataStore
Setting constructor loop
Method batch
Batch sets or deletes data in the store Events: beforeDataBatch Fires before the batch is queued afterDataBatch Fires after the batch is queued failedDataBatch Fires when an exception occurs
Parameters:
type must be a String.
(Type of action to perform ( set/del/delete ))
data must be an Array.
(Array of keys or indices to delete, or Object containing multiple records to set)
sync must be a Boolean.
([Optional] Syncs store with data, if true everything is erased)
Returns an Object
(Deferred)
Method buildUri
Builds a relative URI
Parameters:
Returns a String
([description])
Method clear
Clears the data object, unsets the uri property Events: beforeDataClear Fires before the data is cleared afterDataClear Fires after the data is cleared
Parameters:
Returns an Object
(Data store)
Method crawl
Crawls a record's properties and creates DataStores when URIs are detected Events: beforeDataRetrieve Fires before crawling a record afterDataRetrieve Fires after the store has retrieved all data from crawling failedDataRetrieve Fires if an exception occurs
Parameters:
Returns an Object
(Deferred)
An Array is considered a collection
Relative path to store, i.e. a child
Root path, relative to store, i.e. a domain
Depth of recursion is controled by maxDepth
Relative path to store, i.e. a child
Root path, relative to store, i.e. a domain
Method del
Deletes a record based on key or index Events: beforeDataDelete Fires before the record is deleted afterDataDelete Fires after the record is deleted failedDataDelete Fires if the store is RESTful and the action is denied
Parameters:
record can be of any type.
(Record, key or index)
reindex must be a Boolean.
([Optional] true
if DataStore should be reindexed)
batch must be a Boolean.
([Optional] true
if part of a batch operation)
Returns an Object
(Deferred)
Method delComplete
Delete completion
Parameters:
record must be an Object.
(DataStore record)
reindex must be a Boolean.
(true
if DataStore should be reindexed)
batch must be a Boolean.
(true
if part of a batch operation)
defer must be an Object.
(Deferred instance)
Returns an Object
(DataStore instance)
Public method dump
Exports a subset or complete record set of DataStore
Parameters:
args must be an Array.
([Optional] Sub-data set of DataStore)
fields must be an Array.
([Optional] Fields to export, defaults to all)
Returns an Array
(Records)
Method find
Finds needle in the haystack
Parameters:
needle can be of any type.
(String, Number, RegExp Pattern or Function)
haystack must be a String.
([Optional] Commma delimited string of the field( s ) to search)
modifiers must be a String.
([Optional] Regex modifiers, defaults to "gi" unless value is null)
Returns an Array
(Array of results)
Blocking unnecessary ops
Preparing parameters
No haystack, testing everything
Looking through the haystack
Method get
Retrieves a record based on key or index If the key is an integer, cast to a string before sending as an argument!
Parameters:
record can be of any type.
(Key, index or Array of pagination start & end; or comma delimited String of keys or indices)
offset must be a Number.
([Optional] Offset from record
for pagination)
Returns a Mixed
(Individual record, or Array of records)
Public method join
Performs an (INNER/LEFT/RIGHT) JOIN on two DataStores
Parameters:
arg must be a String.
(DataStore to join)
field must be a String.
(Field in both DataStores)
join must be a String.
(Type of JOIN to perform, defaults to inner
)
Returns an Array
(Array of records)
Method only
Retrieves only 1 field/property
Parameters:
Returns an Array
(Array of values)
Method purge
Purges DataStore or record from localStorage
Parameters:
Returns an Object
(Record or store)
Method reindex
Reindexes the DataStore
Returns an Object
(Data store)
Method restore
Restores DataStore or record frome localStorage
Parameters:
Returns an Object
(Record or store)
Method save
Saves DataStore or record to localStorage, sessionStorage or MongoDB (node.js only)
Parameters:
Returns an Object
(Deferred)
Method select
Selects records based on an explcit description
Parameters:
Returns an Array
(Array of records)
Method set
Creates or updates an existing record Events: beforeDataSet Fires before the record is set afterDataSet Fires after the record is set, the record is the argument for listeners failedDataSet Fires if the store is RESTful and the action is denied
Parameters:
key can be of any type.
([Optional] Integer or String to use as a Primary Key)
data must be an Object.
(Key:Value pairs to set as field values)
batch must be a Boolean.
([Optional] True if called by data.batch)
Returns an Object
(Deferred)
Relative path to store, i.e. a child
Root path, relative to store, i.e. a domain
Method setComplete
Set completion
Parameters:
record can be of any type.
(DataStore record, or null
if new)
key must be a String.
(Record key)
data must be an Object.
(Record data)
batch must be a Boolean.
(true
if part of a batch operation)
defer must be an Object.
(Deferred instance)
Returns an Object
(DataStore instance)
Clearing cached views
Setting key
Removing primary key from data
Create
Update
Method setExpires
Gets or sets an explicit expiration of data
Parameters:
Returns an Object
(Data store)
Expiry cannot be less than a second, and must be a valid scenario for consumption; null will disable repetitive expiration
Method setUri
Sets the RESTful API end point
Parameters:
Returns an Object
(Deferred)
Re-encoding the query string for the request
Method sort
Returns a view, or creates a view and returns it Records in a view are not by reference, they are clones
Parameters:
query must be a String.
(SQL ( style ) order by)
create must be a String.
([Optional, default behavior is true, value is false] Boolean determines whether to recreate a view if it exists)
where must be an Object.
([Optional] Object describing the WHERE clause)
Returns an Array
(View of data)
Storage interface SQL/NoSQL backends will be used if configured in lieu of localStorage (node.js only)
Parameters:
obj can be of any type.
(Record ( Object, key or index ) or store)
op must be an Object.
(Operation to perform ( get, remove or set ))
type must be a String.
([Optional] Type of Storage to use ( local, session [local] ))
Returns an Object
(Deferred)
Removing all documents & re-inserting
Method sync
Syncs the DataStore with a URI representation Events: beforeDataSync Fires before syncing the DataStore afterDataSync Fires after syncing the DataStore failedDataSync Fires when an exception occurs
Returns an Object
(Deferred)
Private method success
Resolves public deferred
Parameters:
Returns an Undefined
(undefined)
Private method failure
Rejects public deferred
Parameters:
Returns an Undefined
(undefined)
Method teardown
Tears down a store & expires all records associated to an API
Returns an Undefined
(undefined)
Method undo
Undoes the last modification to a record, if it exists
Parameters:
key can be of any type.
(Key or index)
version must be a String.
([Optional] Version to restore)
Returns an Object
(Deferred)
Method unique
Returns Array of unique values of key
Parameters:
Returns an Array
(Array of values)
Method update
Applies a difference to a record
Use data.set()
if data
is the complete field set
Parameters:
key can be of any type.
(Key or index)
data must be an Object.
(Key:Value pairs to set as field values)
Returns an Object
(Deferred)
Method decorator
Decorates a DataStore on an Object
Parameters:
obj must be an Object.
(Object)
recs can be of any type.
([Optional] Data to set with this.batch)
args must be an Object.
([Optional] Arguments to set on the store)
Returns an Object
(Decorated Object)