goog.db.Index
Provided By |
---|
Creates an IDBIndex wrapper object. Indexes are associated with object stores and provide methods for looking up objects based on their non-key properties. Should not be created directly, access through the object store it belongs to.
new Index( index )
Parameters |
| ||||
---|---|---|---|---|---|
See Also |
Instance Methods
this.get( key ) → goog.async.Deferred
goog.async.Deferred
Fetches a single object from the object store. Even if there are multiple objects that match the given key, this method will get only one of them.
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.getKey( key ) → goog.async.Deferred
goog.async.Deferred
Looks up a single object from the object store and gives back the key that it's listed under in the object store. Even if there are multiple records that match the given key, this method returns the first.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.getKeyPath() → *
*
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getName() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isUnique() → boolean
boolean
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 = index.openCursor(goog.db.KeyRange.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 |
|