对于仅包含一个项目的以下数据存储
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来检索它。
答案 0 :(得分:0)
您的代码看起来令人困惑,但似乎我理解正确。 从我的角度来看,你有两个选择:
更改商店中商品的ID是个坏主意。