goog.gears.Database
Classgoog.gears.Database
> goog.events.EventTarget
> goog.Disposable
goog.gears.Database(userId, appName)
Class that for accessing a Gears database
userId
{string
}
appName
{string
}
goog.gears.Database.EventType
EnumConstants for transaction event names. … more
goog.gears.Database.TransactionEvent
ClassEvent info for transaction events. … more
.addEventListener(type, handler, opt_capture, opt_handlerScope)
Inherited from goog.events.EventTarget
.
Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched. Supported for legacy but use goog.events.listen(src, type, handler) instead.
type
{string
}
handler
{Function
|Object
}
opt_capture
{boolean
=}
opt_handlerScope
{Object
=}
.addOnDisposeCallback(callback, opt_scope)
Inherited from goog.Disposable
.
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
callback
{!Function
}
opt_scope
{Object
=}
.begin()
Marks the beginning of a database transaction using the default begin type. Does a real BEGIN operation if useTransactions is true for this database and this is the first opened transaction. This will throw an exception if this is a nested begin and is trying to elevate the begin type from the original BEGIN that was processed.
boolean
}
.beginDeferred()
Marks the beginning of a deferred database transaction. Does a real BEGIN operation if useTransactions is true for this database and this is the first opened transaction.
boolean
}
.beginExclusive()
Marks the beginning of an exclusive database transaction. Does a real BEGIN operation if useTransactions is true for this database and this is the first opened transaction. This will throw an exception if this is a nested begin and is trying to elevate the begin type from the original BEGIN that was processed.
boolean
}
.beginImmediate()
Marks the beginning of an immediate database transaction. Does a real BEGIN operation if useTransactions is true for this database and this is the first opened transaction. This will throw an exception if this is a nested begin and is trying to elevate the begin type from the original BEGIN that was processed.
boolean
}
.close()
Closes the database.
.commit()
Marks the end of a successful transaction. Will do a real COMMIT if this the last outstanding transaction unless a nested transaction was closed with a ROLLBACK in which case a real ROLLBACK will be performed.
boolean
}
.creationStack
{string
}Inherited from goog.Disposable
.
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
.dispatchEvent(e)
Inherited from goog.events.EventTarget
.
Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object. If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.
e
{string
|Object
|goog.events.Event
}
boolean
}
.dispose()
Inherited from goog.Disposable
.
Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
void
}
.disposeInternal()
[protected]Unattach listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners, it should be something like this:
MyClass.prototype.disposeInternal = function() { MyClass.superClass_.disposeInternal.call(this); // Dispose logic for MyClass };
.ensureNoTransaction(opt_logMsgPrefix)
Ensures there is no open transaction upon return. An existing open transaction is rolled back.
opt_logMsgPrefix
{string
=}
.execute(sql, var_args)
Execute a sql statement with a set of arguments
sql
{string
}
var_args
{...*}
GearsResultSet
}
.forEachRow(sql, f, opt_this, var_args)
For each row in the result set f will be called with the following parameters: row (array of values), rowIndex and columnNames. Rows will continue being processed as long as f returns true.
sql
{string
}
f
{Function
}
opt_this
{Object
=}
var_args
{...*}
.forEachValue(sql, f, opt_this, var_args)
For each value in the result set f will be called with the following parameters; value, rowIndex, columnIndex, columnName. Values will continue being processed as long as f returns true.
sql
{string
}
f
{Function
}
opt_this
{Object
=}
var_args
{...*}
.getDisposed
[deprecated]Deprecated. Use {@link #isDisposed} instead.
Inherited from goog.Disposable
.
boolean
}
.getExecutionTime()
Returns the time in Ms that database operations have currently consumed. This only exists in debug builds, but it still may be useful for goog.gears.Trace.
number
}
.getLastInsertRowId()
number
}
.getParentEventTarget()
Inherited from goog.events.EventTarget
.
Returns the parent of this event target to use for bubbling.
goog.events.EventTarget
}
.getUseTransactions()
Whether transactions are used for the database
boolean
}
.isDisposed()
Inherited from goog.Disposable
.
boolean
}
.isInTransaction()
Returns whether or not we're in a transaction.
boolean
}
.isLockedException(ex)
Determines if the exception is a locking error.
ex
{Error
|string
}
boolean
}
.needsRollback()
Returns whether or not the current transaction has a pending rollback. Returns false if there is no current transaction.
boolean
}
.open()
Opens the database.
.queryArray(sql, var_args)
This calls query on the database and returns the first row as an array
sql
{string
}
var_args
{...*}
Array
}
.queryArrays(sql, var_args)
This calls query on the database and builds a two dimensional array containing the result.
sql
{string
}
var_args
{...*}
Array
}
.queryObject(sql, var_args)
This calls query on the database and returns the first row as a hash map where the keys are the column names.
sql
{string
}
var_args
{...*}
Object
}
.queryObjectArray(sql, var_args)
This calls query on the database and builds an array containing hashes
sql
{string
}
var_args
{...*}
Array
}
.queryValue(sql, var_args)
This calls query on the database and returns the first value in the first row.
sql
{string
}
var_args
{...*}
number
,string
,null
)}
.queryValueArray(sql, var_args)
This calls query on the database and returns an array containing the values in the first column. This is useful if the result set only contains one column.
sql
{string
}
var_args
{...*}
Array
}
.registerDisposable(disposable)
Inherited from goog.Disposable
.
Associates a disposable object with this object so that they will be disposed together.
disposable
{goog.disposable.IDisposable
}
.remove()
Removes the database.
.removeEventListener(type, handler, opt_capture, opt_handlerScope)
Inherited from goog.events.EventTarget
.
Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.
type
{string
}
handler
{Function
|Object
}
opt_capture
{boolean
=}
opt_handlerScope
{Object
=}
.resultSetToArray(rs)
Returns an array of the first row in the result set
rs
{GearsResultSet
}
Array
}
.resultSetToArrays(rs)
Returns an array of arrays, where each sub array contains the selected values for each row in the result set. result values
rs
{GearsResultSet
}
Array
}
.resultSetToObject(rs)
Returns a single hashed object from the result set (the first row), where the column names in the query are used as the members of the object.
rs
{GearsResultSet
}
Object
}
.resultSetToObjectArray(rs)
Returns a array of hash objects, one per row in the result set, where the column names in the query are used as the members of the object.
rs
{GearsResultSet
}
Array
.<Object
>}
.resultSetToValue(rs)
Returns a single value from the results (first column in first row).
rs
{GearsResultSet
}
number
,string
,null
)}
.resultSetToValueArray(rs)
Returns an array containing the first item of each row in a result set. This is useful for query that returns one column
rs
{GearsResultSet
}
Array
.<Object
>}
.rollback(opt_e)
Marks the end of an unsuccessful transaction. Will do a real ROLLBACK if this the last outstanding transaction, otherwise the real ROLLBACK will be deferred until the last outstanding transaction is closed.
opt_e
{Error
=}
boolean
}
.setDefaultBeginType(beginType)
Sets the default begin type.
beginType
{string
}
.setParentEventTarget(parent)
Inherited from goog.events.EventTarget
.
Sets the parent of this event target to use for bubbling.
parent
{goog.events.EventTarget
?}
.setUseTransactions(b)
Whether transactions are used for the database
b
{boolean
}
.transact(func)
Executes a function transactionally.
func
{Function
}
Object
|number
|boolean
|string
|null
|undefined
}