The goog.db.IndexedDb Class

goog.db.IndexedDb(db)

Creates an IDBDatabase wrapper object. The database object has methods for setting the version to change the structure of the database and for creating transactions to get or modify the stored records. Should not be created directly, call {@link goog.db.openDatabase} to set up the connection.

db {!IDBDatabase}
Underlying IndexedDB database object.

.close()

Closes the database connection. Metadata queries can still be made after this method is called, but otherwise this wrapper should not be used further.

.createObjectStore(name, opt_params)

Creates an object store in this database. Can only be called inside the callback for the Deferred returned from #setVersion.

name {string}
Name for the new object store.
opt_params {Object=}
Options object. The available options are: keyPath, which is a string and determines what object attribute to use as the key when storing objects in this object store; and autoIncrement, which is a boolean, which defaults to false and determines whether the object store should automatically generate keys for stored objects. If keyPath is not provided and autoIncrement is false, then all insert operations must provide a key as a parameter.
returns {goog.db.ObjectStore}
The newly created object store.
@throws
{goog.db.Error} If there's a problem creating the object store.

.createTransaction(storeNames, opt_mode)

Creates a new transaction.

storeNames {!Array.<string>}
A list of strings that contains the transaction's scope, the object stores that this transaction can operate on.
opt_mode {goog.db.Transaction.TransactionMode=}
The mode of the transaction. If not present, the default is READ_ONLY. For VERSION_CHANGE transactions call {@link goog.db.IndexedDB#setVersion} instead.
returns {!goog.db.Transaction}
The wrapper for the newly created transaction.
@throws
{goog.db.Error} If there's a problem creating the transaction.

.deleteObjectStore(name)

Deletes an object store. Can only be called inside the callback for the Deferred returned from #setVersion.

name {string}
Name of the object store to delete.
@throws
{goog.db.Error} If there's a problem deleting the object store.

.getName()

returns {string}
The name of this database.

.getObjectStoreNames()

returns {Array}
List of object stores in this database.

.getVersion()

returns {string}
The current database version.

.isOpen()

returns {boolean}
Whether a connection is open and the database can be used.

.setVersion(version)

Updates the version of the database and returns a Deferred transaction. The database's structure can be changed inside this Deferred's callback, but nowhere else. This means adding or deleting object stores, and adding or deleting indexes. The version change will not succeed unless there are no other connections active for this database anywhere. A new database connection should be opened after the version change is finished to pick up changes.

version {string}
The new version of the database.
returns {!goog.async.Deferred}
The deferred transaction for changing the version.