This is a basic in-memory object store. It implements dojo/store/api/Store.
Parameter | Type | Description |
---|---|---|
options | dojo/store/Memory | This provides any configuration information that will be mixed into the store. This should generally include the data property to provide the starting set of data. |
See the dojo/store/Memory reference documentation for more information.
Indicates the property to use as the identity property. The values of this property should be unique.
Creates an object, throws an error if the object already exists
Parameter | Type | Description |
---|---|---|
object | Object | The object to store. |
options | dojo/store/api/Store.PutDirectives |
Optional Additional metadata for storing the data. Includes an "id" property if a specific id is to be used. |
Retrieves an object by its identity
Parameter | Type | Description |
---|---|---|
id | Number | The identity to use to lookup the object |
The object in the store that matches the given id.
Retrieves the children of an object.
Parameter | Type | Description |
---|---|---|
parent | Object | The object to find the children of. |
options | dojo/store/api/Store.QueryOptions |
Optional Additional options to apply to the retrieval of the children. |
A result set of the children of the parent object.
Returns an object's identity
Parameter | Type | Description |
---|---|---|
object | Object | The object to get the identity from |
Returns any metadata about the object. This may include attribution, cache directives, history, or version information.
Parameter | Type | Description |
---|---|---|
object | Object | The object to return metadata for. |
An object containing metadata.
Stores an object
Parameter | Type | Description |
---|---|---|
object | Object | The object to store. |
options | dojo/store/api/Store.PutDirectives |
Optional Additional metadata for storing the data. Includes an "id" property if a specific id is to be used. |
Queries the store for objects.
Parameter | Type | Description |
---|---|---|
query | Object | The query to use for retrieving objects from the store. |
options | dojo/store/api/Store.QueryOptions |
Optional The optional arguments to apply to the resultset. |
The results of the query, extended with iterative methods.
Given the following store:
1 2 3 4 5 6 7 8 9 | var store = new Memory({ data: [ {id: 1, name: "one" , prime: false }, {id: 2, name: "two" , even: true , prime: true }, {id: 3, name: "three" , prime: true }, {id: 4, name: "four" , even: true , prime: false }, {id: 5, name: "five" , prime: true } ] }); |
...find all items where "prime" is true:
1 | var results = store.query({ prime: true }); |
...or find all items where "even" is true:
1 | var results = store.query({ even: true }); |
Defines the query engine to use for querying the data store
Parameter | Type | Description |
---|---|---|
query | Object | An object hash with fields that may match fields of items in the store. Values in the hash will be compared by normal == operator, but regular expressions or any object that provides a test() method are also supported and can be used to match strings by more complex expressions (and then the regex's or object's test() method will be used to match values). |
options | dojo/store/api/Store.QueryOptions |
Optional An object that contains optional information such as sort, start, and count. |
A function that caches the passed query under the field "matches". See any of the "query" methods on dojo.stores.
Deletes an object by its identity
Parameter | Type | Description |
---|---|---|
id | Number | The identity to use to delete the object |
Returns true if an object was removed, falsy (undefined) if no object matched the id
Sets the given data as the source for this store, and indexes it
Parameter | Type | Description |
---|---|---|
data | Object[] | An array of objects to use as the source of data. |
Starts a new transaction. Note that a store user might not call transaction() prior to using put, delete, etc. in which case these operations effectively could be thought of as "auto-commit" style actions.
This represents the new current transaction.