dojo - Store/Memory

dojo - Store/Memory

by Lavakumar T

JavaScript

require(["dojo/store/Memory"], function(Memory){
    var someData = [
        {id:1, name:"One"},
        {id:2, name:"Two"},
        {id:7, name:"Seven"},
        {id:3, name:"Three"},
        {id:5, name:"Five"},
        {id:4, name:"Four"},
        {id:6, name:"Six"}
    ];
    store = new Memory({data: someData});
    store.query({name:"One"}); // Returns query results from the array that match the given query
    console.log( store.query({name:"One"}));
    store.query(function(object){
        return object.id > 1;
    }); // Pass a function to do more complex querying

    store.query({name:"One"}, {sort: [{attribute: "id"}]}); // Returns query results and sort by id

    store.put({id:3, name:"Three"}); // store the object with the given identity
		console.log(store);
    store.remove(3); // delete the object
});