对于以下只包含一个项目的数据存储区,
var Model = require('dmodel/Model');
var Memory = require('dstore/Memory');
var jsonSchema = require('dmodel/extensions/jsonSchema');
var declare = require('dojo/_base/declare');
var formStore = (declare([Memory]))({
Model: jsonSchema(formSchema),
idProperty: "formId",
});
var formProperties = {
"formName": "formName",
"formId": 'xyz',
"formType": 'formType'
};
formStore.setData([formProperties]);
我想做以下事情
var item = formStore.getSync('xyz');
//get a property object from an data object,
var property = item.property('formId');
//request a change in the value of this property
property.put('abc');
formStore.getIdentity(formStore.data[0]) //returns 'abc'
**BUT**
formStore.getSync('abc') //returns undefined, even though it shows as 'abc' in the data array.
即使属性的值发生了变化,我也无法通过新的ID检索它。
1条答案
按热度按时间g2ieeal71#
你的代码看起来很混乱,但我似乎理解正确。从我的Angular 来看,你有两个选择:
1.使用另一个值作为idProperty,该值不会被更改;
1.删除初始项并使用新ID放置新项;
更改存储区中项目的ID是个坏主意。