I am using YDN DB for IndexedDB and I want to delete a record from the object store using its id. Here is my schema:
var personsSchema = {
name: "persons",
keyPath: "id",
autoIncrement: true,
indexes: [{
name: "id",
unique: true
}, {
name: "firstname",
unique: false,
multiEntry: false
}, {
name: "lastname",
unique: false,
multiEntry: false
}]
};
schema = {
stores: [personsSchema]
};
var db = new ydn.db.Storage("xdb", schema);
Now, I have function that will delete the record:
function deleteEntry(id){
var id = parseInt(id);
var objectStore = "persons";
var iterator = new ydn.db.ValueCursors(objectStore, "id", ydn.db.KeyRange.only(id));
var mode = "readwrite";
request = db.open(iterator, 1).then(function(cursor){
cursor.clear();
}, mode);
}
This function gives me this error:
Uncaught ydn.error.ArgumentException: Second argument must be cursor range iterator.
Thank you for responses.