Reputation: 1158
I'm using YDN-DB as my indexeddb wrapper; I've read the user guide and api, and have absolutely no idea how you'd update a record by id (primary key [auto incremented]).
Is anyone familiar with this/have any idea?
http://dev.yathit.com/ydn-db/getting-started.html
Upvotes: 3
Views: 1042
Reputation: 1158
Figured it out (finally) - thanks for the great library Kyaw!
The following code works:
record = {id: 1, "setting": "test", "value": "value"};
req = db.put({name: 'tblSettings', keyPath: 'id'}, record);
req.done(function(key) {
console.log(key);
});
req.fail(function(e) {
throw e;
});
Upvotes: 1
Reputation: 13151
You can update value of a record using put
method by identifying the record by its primary key.
For store using auto generated key (autoIncrement), the primary key is known in the callback when you insert the record via add
or put
method. Primary key can be queried or canonically constructed. For example, a contact object may use its email address as primary key. You can get all primary keys in a store by keys
method.
Upvotes: 0