Permalink
Browse files

Change a number of indexedDB functions to take primitive and array ty…

…pes instead of !Object type for keys and * for values, in accordance with the documentation at https://developer.mozilla.org/en-US/docs/IndexedDB and http://www.w3.org/TR/IndexedDB/#key-construct

This includes the final changes to the Index and Cursor classes, and corresponding extern changes

This has the potential to introduce compiler type-check errors

R=nicksantos
DELTA=36 (0 added, 6 deleted, 30 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=6110


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2426 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
1 parent b378891 commit e5d63e508f6b7810222817d3d91eb5ec78bd2943 jmoon@google.com committed Jan 9, 2013
Showing with 24 additions and 24 deletions.
  1. +7 −7 closure/goog/db/cursor.js
  2. +17 −17 closure/goog/db/index.js
View
14 closure/goog/db/cursor.js
@@ -52,13 +52,13 @@ goog.db.Cursor.prototype.cursor_ = null;
/**
* Advances the cursor to the next position along its direction. When new data
- * is availible, the NEW_DATA event will be fired. If the cursor has reached the
+ * is available, the NEW_DATA event will be fired. If the cursor has reached the
* end of the range it will fire the COMPLETE event. If opt_key is specified it
* will advance to the key it matches in its direction.
*
* This wraps the native #continue method on the underlying object.
*
- * @param {!Object=} opt_key The optional key to advance to.
+ * @param {IDBKeyType=} opt_key The optional key to advance to.
*/
goog.db.Cursor.prototype.next = function(opt_key) {
if (opt_key) {
@@ -74,7 +74,7 @@ goog.db.Cursor.prototype.next = function(opt_key) {
* If the cursor points to a value that has just been deleted, a new value is
* created.
*
- * @param {!Object} value The value to be stored.
+ * @param {*} value The value to be stored.
* @return {!goog.async.Deferred} The resulting deferred request.
*/
goog.db.Cursor.prototype.update = function(value) {
@@ -130,7 +130,7 @@ goog.db.Cursor.prototype.remove = function() {
/**
- * @return {Object} The value for the value at the cursor's position. Undefined
+ * @return {*} The value for the value at the cursor's position. Undefined
* if no current value, or null if value has just been deleted.
*/
goog.db.Cursor.prototype.getValue = function() {
@@ -139,8 +139,8 @@ goog.db.Cursor.prototype.getValue = function() {
/**
- * @return {*} The key for the value at the cursor's position. If the
- * cursor is outside its range, this is undefined.
+ * @return {IDBKeyType} The key for the value at the cursor's position. If
+ * the cursor is outside its range, this is undefined.
*/
goog.db.Cursor.prototype.getKey = function() {
return this.cursor_.key;
@@ -164,7 +164,7 @@ goog.db.Cursor.Direction = {
/**
* Event types that the cursor can dispatch. COMPLETE events are dispatched when
* a cursor is depleted of values, a NEW_DATA event if there is new data
- * availible, and ERROR if an error occurred.
+ * available, and ERROR if an error occurred.
*
* @enum {string}
*/
View
34 closure/goog/db/index.js
@@ -77,25 +77,25 @@ goog.db.Index.prototype.isUnique = function() {
*
* @param {string} fn Function name to call on the index to get the request.
* @param {string} msg Message to give to the error.
- * @param {!Object} value Value to look up in the index.
+ * @param {IDBKeyType} key The key to look up in the index.
* @return {!goog.async.Deferred} The resulting deferred object.
* @private
*/
-goog.db.Index.prototype.get_ = function(fn, msg, value) {
+goog.db.Index.prototype.get_ = function(fn, msg, key) {
var d = new goog.async.Deferred();
var request;
try {
- request = this.index_[fn](value);
+ request = this.index_[fn](key);
} catch (err) {
- msg += ' with value ' + goog.debug.deepExpose(value);
+ msg += ' with key ' + goog.debug.deepExpose(key);
d.errback(goog.db.Error.create(err, msg));
return d;
}
request.onsuccess = function(ev) {
d.callback(ev.target.result);
};
request.onerror = function(ev) {
- msg += ' with value ' + goog.debug.deepExpose(value);
+ msg += ' with key ' + goog.debug.deepExpose(key);
d.errback(new goog.db.Error(
(/** @type {IDBRequest} */ (ev.target)).errorCode,
msg));
@@ -106,27 +106,27 @@ goog.db.Index.prototype.get_ = function(fn, msg, value) {
/**
* Fetches a single object from the object store. Even if there are multiple
- * objects that match the given value, this method will get only one of them.
+ * objects that match the given key, this method will get only one of them.
*
- * @param {!Object} value Value to look up in the index.
- * @return {!goog.async.Deferred} The deferred object that matches the value.
+ * @param {IDBKeyType} key Key to look up in the index.
+ * @return {!goog.async.Deferred} The deferred object for the given record.
*/
-goog.db.Index.prototype.get = function(value) {
- return this.get_('get', 'getting from index ' + this.getName(), value);
+goog.db.Index.prototype.get = function(key) {
+ return this.get_('get', 'getting from index ' + this.getName(), key);
};
/**
* 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 objects
- * that match the given value, this method will only get one of their keys.
+ * it's listed under in the object store. Even if there are multiple records
+ * that match the given key, this method returns the first.
*
- * @param {!Object} value Value to look up in the index.
- * @return {!goog.async.Deferred} The deferred key for the object that matches
- * the value.
+ * @param {IDBKeyType} key Key to look up in the index.
+ * @return {!goog.async.Deferred} The deferred key for the record that matches
+ * the key.
*/
-goog.db.Index.prototype.getKey = function(value) {
- return this.get_('getKey', 'getting key from index ' + this.getName(), value);
+goog.db.Index.prototype.getKey = function(key) {
+ return this.get_('getKey', 'getting key from index ' + this.getName(), key);
};

0 comments on commit e5d63e5

Please sign in to comment.