goog.db.ObjectStore
Classgoog.db.ObjectStore(store)
Creates an IDBObjectStore wrapper object. Object stores have methods for storing and retrieving records, and are accessed through a transaction object. They also have methods for creating indexes associated with the object store. They can only be created when setting the version of the database. Should not be created directly, access object stores through transactions.
store
{!IDBObjectStore
}
.add(value, opt_key)
Adds an object to the object store. Requires that there is no object with the same key already present.
value
{!Object
}
opt_key
{!Object
=}
goog.async.Deferred
}
.clear()
Deletes all objects from the store.
goog.async.Deferred
}
.createIndex(name, keyPath, opt_parameters)
Creates an index in this object store. Can only be called inside the callback for the Deferred returned from goog.db.IndexedDb#setVersion.
name
{string
}
keyPath
{string
}
opt_parameters
{!Object
=}
goog.db.Index
}
.deleteIndex(name)
Deletes an index from the object store. Can only be called inside the callback for the Deferred returned from goog.db.IndexedDb#setVersion.
name
{string
}
.get(key)
Gets an object from the store. If no object is present with that key the result is {@code undefined}.
key
{!Object
}
goog.async.Deferred
}
.getAll(opt_range, opt_direction)
Gets all objects from the store and returns them as an array.
opt_range
{!goog.db.KeyRange
=}
opt_direction
{!goog.db.Cursor.Direction
=}
goog.async.Deferred
}
.getIndex(name)
Gets an index.
name
{string
}
goog.db.Index
}
.getName()
string
}
.openCursor(opt_range, opt_direction)
Opens a cursor over the specified key range. Returns a cursor object which is
able to iterate over the given range.
Example usage:
var cursor = objectStore.openCursor(goog.db.Range.bound('a', 'c'));
var key = goog.events.listen(
cursor, goog.db.Cursor.EventType.NEW_DATA, function() {
// Do something with data.
cursor.next();
});
goog.events.listenOnce(
cursor, goog.db.Cursor.EventType.COMPLETE, function() {
// Clean up listener, and perform a finishing operation on the data.
goog.events.unlistenByKey(key);
});
opt_range
{!goog.db.KeyRange
=}
opt_direction
{!goog.db.Cursor.Direction
=}
goog.db.Cursor
}
.put(value, opt_key)
Adds an object to the object store. Replaces existing objects with the same key.
value
{!Object
}
opt_key
{!Object
=}
goog.async.Deferred
}
.remove(key)
Removes an object from the store. No-op if there is no object present with the given key.
key
{!Object
}
goog.async.Deferred
}