你的位置:首页 > 软件开发 > Java > dojo/store/Memory 和 SimpleQueryEngine 解读 (非常简单的存储器管理工具 和 非常简单的查询引擎)

dojo/store/Memory 和 SimpleQueryEngine 解读 (非常简单的存储器管理工具 和 非常简单的查询引擎)

发布时间:2016-09-22 16:00:16
一、介绍(官方API):The Memory store provides full read and write capabilities for in memory data. The Memory store is very simple to use, just prov ...

一、介绍(官方API):

The Memory store provides full read and write capabilities for in memory data. The Memory store is very simple to use, just provide an array of objects. The Memory store is also a synchronous store, which also simplifies its usage. All the functions directly return results, so you don’t have to use asynchronous callbacks in your code.

大致翻译:Memory store 提供了对内存可读可写的管理单元。它非常简单,易于使用,内部仅提供了一个对象数组。Memory store是一个同步存储器,自然功能简单易用了。所有的方法都是直接返回结果,你不需要去编写异步的回调函数

Example:

require(["dojo/store/Memory"], function(Memory){  var someData = [    {id:1, name:"One"},    {id:2, name:"Two"}  ];  store = new Memory({data: someData});  store.get(1) -> Returns the object with an id of 1  store.query({name:"One"}) // 根据特定的查询条件,返回符合要求的结果集。  store.query(function(object){    return object.id > 1;  }) // 通过传递一个函数来进行查询,可以实现更复杂的查询操作  store.query({name:"One"}, {sort: [{attribute: "id"}]}) // 除了查询以外,返回的结果集会根据id来排序。  store.put({id:3, name:"Three"}); //保存{id:3, name:"Three"} 对象,并且放在id:3的位置。  store.remove(3); // 根据ID来删除对象});
又假如:query={  test:function(object){    rreturn (object.peopleNum>10} }, grade:2,}//查询结果为对象peopleNum属性大于10,且grade等于2的结果,即//[// {id:5,grade:2,class:2,peopleNum:20}//]

原标题:dojo/store/Memory 和 SimpleQueryEngine 解读 (非常简单的存储器管理工具 和 非常简单的查询引擎)

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录