- 1、本文档共14页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
dojostoreMemory 和 SimpleQueryEngine 解读
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来删除对象});? 官方API的介绍和切合要点,Memory store的最显著的特点,就是“简单”。Memory store的功能就像上面的例子中的一样,简单暴力,基本齐全。下面我们根据dojo里的源码进一步解析:?构造函数constructor: constructor: function(options){// summary:// Creates a memory object store.// 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.for(var i in options){this[i] = options[i]; }this.setData(this.data || []); }, 嗯,我们通过new字段来创建memory store到对象时,就会调用到这里。案例中的options参数为{data:somedata}。实际上是创建了最最简单的Memory stortt仅仅只用了一个对象数组。所以当然咯,可以有略复杂一点的情况。代码中this[i]=options[i],可以看出各种配置都体现在Menory对象的属性里。下面列一下: // data: Array// The array of all the objects in the memory store data:null,// idProperty: String// Indicates the property to use as the identity property. The values of this// property should be unique. idProperty: id,// index: Object// An index of data indices into the data array by id index:null,// queryEngine: Function// Defines the query engine to use for querying the data store queryEngine: SimpleQueryEngine, data:是必须的,如果不存在,会被赋予一个[]空数组。 index:后续会提到这个属性,它是一个以id(idProperty) 为索引的表,表的数据是一个改id对应的属性在data数组里的序号索引。 idProperty:啊哈,通过这个属性我们可指定改memory的一个不可重复的标识符(字段名),默认是为id。 queryEngine:可以指定memory的搜搜引擎,默认使用的是dojo/store/util/SimpleQueryEngine。?setData: function(data){// summary:// Sets the given data as the
您可能关注的文档
- QOS(PQ+CQ+WFQ+CBWFQ+LLQ)配置实例.docx
- 数据结构 舞伴搭配问题完全代码.doc
- 初一期中测试卷(A)—海淀西城区.docx
- 第三次数据结构上机实验报告.doc
- 了解SpringDataJPA.docx
- CHOLESTYRAMINE 考来烯胺(可林斯提拉明酯)台湾 ,用药 ,说明.doc
- 老人与海英文版读后感.docx
- 主持人串词(贵士暨G-TR上市活动).doc
- 外贸函电A卷(统本)-周瑞芳.doc
- 魔王语言报告(带有完整程序).doc
- 新视野二版听说1第6单元示范1课件.ppt
- 【参考答案】 联络口译(第二版) 《联络口译》(第二版)参考答案.pdf
- 梅大高速茶阳路段“5·1”塌方灾害调查评估报告.docx
- 虹吸雨水PE管施工节点标准做法.pdf
- 2025消防设施施工质量常见通病防治手册,典型图示+规范要求.pptx
- 新视野大学英语(第二版)读写教程 4 空军工程大学编U05B.ppt
- E英语教程2(智慧版)Unit 6.pptx
- E英语教程3(智慧版)Unit 7.ppt
- 新视野二版读写1第4单元课件Section A How to Make a Good Impression.pptx
- E英语视听说教程4(智慧版)4-U2课件(2024版)U2.pptx
文档评论(0)