Reputation: 11613
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?
Upvotes: 2
Views: 3791
Reputation: 56
I think you can use the {multientry: true}
parameter of createIndex for that.
Upvotes: 4
Reputation: 1202
Something 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));
}
Upvotes: 5