goog.db.ObjectStore
Provided By |
---|
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.
new ObjectStore( store )
Parameters |
| ||||
---|---|---|---|---|---|
See Also |
Instance Methods
this.add( value, opt_key ) → goog.async.Deferred
goog.async.Deferred
Adds an object to the object store. Requires that there is no object with the same key already present.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.clear() → goog.async.Deferred
goog.async.Deferred
Deletes all objects from the store.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.count( opt_range ) → goog.async.Deferred
goog.async.Deferred
Gets number of records within a key range.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.createIndex( name, keyPath, opt_parameters ) → goog.db.Index
goog.db.Index
Creates an index in this object store. Can only be called inside a
goog.db.UpgradeNeededCallback
.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||||||
Throws |
|
this.deleteIndex( name ) → void
void
Deletes an index from the object store. Can only be called inside a
goog.db.UpgradeNeededCallback
.
Parameters |
| ||||
---|---|---|---|---|---|
Throws |
|
this.get( key ) → goog.async.Deferred
goog.async.Deferred
Gets an object from the store. If no object is present with that key
the result is undefined
.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.getAll( opt_key, opt_count ) → goog.async.Deferred
goog.async.Deferred
Returns the values matching opt_key
up to opt_count
.
If obt_key
is a KeyRange
, returns all keys in that range. If it is
undefined
, returns all known keys.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.getAllKeys( opt_key, opt_count ) → goog.async.Deferred
goog.async.Deferred
Returns the keys matching opt_key
up to opt_count
.
If obt_key
is a KeyRange
, returns all keys in that range. If it is
undefined
, returns all known keys.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.getIndex( name ) → goog.db.Index
goog.db.Index
Gets an index.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
| ||||
Throws |
|
this.getName() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.openCursor( opt_range, opt_direction ) → goog.db.Cursor
goog.db.Cursor
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);
});
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
Throws |
|
this.put( value, opt_key ) → goog.async.Deferred
goog.async.Deferred
Adds an object to the object store. Replaces existing objects with the same key.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.remove( keyOrRange ) → goog.async.Deferred
goog.async.Deferred
Removes an object from the store. No-op if there is no object present with the given key.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|