db.ObjectStore Extends
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.

Inheritance

Constructor

goog.db.ObjectStore(store)

Parameters

store : !IDBObjectStore
The backing IndexedDb object.

Instance Methods

Public Protected Private
add(valueopt_key) !goog.async.Deferred
Adds an object to the object store. Requires that there is no object with the same key already present.
Arguments:
value : *
The value to add.
opt_key : IDBKeyType=
The key to use. Cannot be used if the keyPath was specified for the object store. If the keyPath was not specified but autoIncrement was not enabled, it must be used.
Returns: !goog.async.Deferred  The deferred add request.
code »
clear() !goog.async.Deferred
Deletes all objects from the store.
Returns: !goog.async.Deferred  The deferred clear request.
code »
count(opt_range) !goog.async.Deferred
Gets number of records within a key range.
Arguments:
opt_range : !goog.db.KeyRange=
The key range. If undefined, this will count all records in the object store.
Returns: !goog.async.Deferred  The deferred number of records.
code »
createIndex(namekeyPathopt_parameters) !goog.db.Index
Creates an index in this object store. Can only be called inside the callback for the Deferred returned from goog.db.IndexedDb#setVersion.
Arguments:
name : string
Name of the index to create.
keyPath : string
Attribute to index on.
opt_parameters : !Object=
Optional parameters object. The only available option is unique, which defaults to false. If unique is true, the index will enforce that there is only ever one object in the object store for each unique value it indexes on.
Returns: !goog.db.Index  The newly created, wrapped index.
code »
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.
Arguments:
name : string
Name of the index to delete.
code »
get(key) !goog.async.Deferred
Gets an object from the store. If no object is present with that key the result is undefined.
Arguments:
key : IDBKeyType
The key to look up.
Returns: !goog.async.Deferred  The deferred get request.
code »
getAll(opt_rangeopt_direction) !goog.async.Deferred
Gets all objects from the store and returns them as an array.
Arguments:
opt_range : !goog.db.KeyRange=
The key range. If undefined iterates over the whole object store.
opt_direction : !goog.db.Cursor.Direction=
The direction. If undefined moves in a forward direction with duplicates.
Returns: !goog.async.Deferred  The deferred getAll request.
code »
getIndex(name) !goog.db.Index
Gets an index.
Arguments:
name : string
Name of the index to fetch.
Returns: !goog.db.Index  The requested wrapped index.
code »
getName() string
No description.
Returns: string  The name of the object store.
code »
insert_(fnmsgvalueopt_key) !goog.async.Deferred
Helper function for put and add.
Arguments:
fn : string
Function name to call on the object store.
msg : string
Message to give to the error.
value : *
Value to insert into the object store.
opt_key : IDBKeyType=
The key to use.
Returns: !goog.async.Deferred  The resulting deferred request.
code »
openCursor(opt_rangeopt_direction) !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); });
Arguments:
opt_range : !goog.db.KeyRange=
The key range. If undefined iterates over the whole object store.
opt_direction : !goog.db.Cursor.Direction=
The direction. If undefined moves in a forward direction with duplicates.
Returns: !goog.db.Cursor  The cursor.
code »
put(valueopt_key) !goog.async.Deferred
Adds an object to the object store. Replaces existing objects with the same key.
Arguments:
value : *
The value to put.
opt_key : IDBKeyType=
The key to use. Cannot be used if the keyPath was specified for the object store. If the keyPath was not specified but autoIncrement was not enabled, it must be used.
Returns: !goog.async.Deferred  The deferred put request.
code »
remove(key) !goog.async.Deferred
Removes an object from the store. No-op if there is no object present with the given key.
Arguments:
key : IDBKeyType
The key to remove objects under.
Returns: !goog.async.Deferred  The deferred remove request.
code »

Instance Properties

store_ :
Underlying IndexedDB object store object.
Code »

Package db

Package Reference