Open a2prn opened 10 years ago
Please refer to indexeddb documentation https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB to learn how to create indexes (on array elements).
Thanks webcss, I am able to create index on array element if I have object like this,
var data = { teacher : { name : "Mack", subject : "Maths" }, Student : ["Mark" , "John"] }
by using: store.createIndex("indexname","data .Student", {unique:false,multiEntry:true});
But I am not able to create index on array of object element.
eg: var data = { teacher : { name : "Mack", subject : "Maths" }, Student : [{ studname : "Alex", stud_id : 1 },{ stud_name : "Jack", stud_id : 2 },{ stud_name : "Mark", stud_id : 3 }] };
In object above data object has Student array, which has multiple objects. And I want to create index on array of object (data.Student.stud_name). Is it possible to create such type of index?
As proposed here https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB#Structuring_the_database it definitly is possible to solve your problem.
Has there been a solution to this? The specified link does not say much
It currently is not possible to create an index from a property of an object in an array of objects. There was an issue filed for the spec that you can follow here: https://github.com/w3c/IndexedDB/issues/35
I have an object.
var _data = { teacher : { name : "Mack", subject : "Maths" }, Student : [{ stud_name : "Alex", stud_id : 1 },{ stud_name : "Jack", stud_id : 2 },{ stud_name : "Mark", stud_id : 3 }] };
I want to create index on array element of object. i.e, I want to create an index on stud_name. Is it possible to create such type of index in indexeddb?