admin管理员组文章数量:1334124
I think the answer is "you can't do it that way", but I wanted to be sure. Let's say I have an object:
var person = {
name: 'Joe',
phoneNumbers: [ '5555554455', '4445554455' ]
};
I want to create an index on phoneNumbers:
objectStore.createIndex('phoneNumberIndex', 'phoneNumbers');
Later I want to query for persons with a particular phoneNumber:
index.get('4445554455').onsuccess = function(event) {
// Anything?
};
Will that produce a result? If not, is there another way to do this?
I think the answer is "you can't do it that way", but I wanted to be sure. Let's say I have an object:
var person = {
name: 'Joe',
phoneNumbers: [ '5555554455', '4445554455' ]
};
I want to create an index on phoneNumbers:
objectStore.createIndex('phoneNumberIndex', 'phoneNumbers');
Later I want to query for persons with a particular phoneNumber:
index.get('4445554455').onsuccess = function(event) {
// Anything?
};
Will that produce a result? If not, is there another way to do this?
Share Improve this question asked Jan 18, 2012 at 18:51 MatthewMatthew 11.6k9 gold badges40 silver badges45 bronze badges2 Answers
Reset to default 5Something like this should work:
objectStore.createIndex("phoneNumberIndex", "phoneNumber", { multiEntry: true });
objectStore.index("phoneNumberIndex").get("4445554455").onsuccess = function(e) {
console.log(JSON.stringify(e.target.result));
}
I think you can use the {multientry: true}
parameter of createIndex for that.
本文标签: javascriptIndexedDB Query index where value quotcontainsquotStack Overflow
版权声明:本文标题:javascript - IndexedDB: Query index where value "contains" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742357904a2459785.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论