Game Development Reference
In-Depth Information
dexedDB. To specify that we want auto-incremented values, we simply add the flag
to the object store properties object when the data store is first created (or upgraded)
as shown in the following code snippet:
request.onupgradeneeded = function(event) {
var settings = {
keyPath: "myKey",
autoIncrement: true
};
db = event.target.result;
store = db.createObjectStore("myDataStore",
settings);
};
Now we can persist an object without having to provide a unique value for the prop-
erty myKey . As a matter of fact, we don't even need to provide this attribute at all as
part of any objects we store here. IndexedDB will handle that for us. Take a look at
the following diagram:
Search WWH ::




Custom Search