Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit e5d63e508f6b7810222817d3d91eb5ec78bd2943 1 parent b378891
jmoon@google.com authored

Showing 2 changed files with 24 additions and 24 deletions. Show diff stats Hide diff stats

  1. +7 7 closure/goog/db/cursor.js
  2. +17 17 closure/goog/db/index.js
14 closure/goog/db/cursor.js
@@ -52,13 +52,13 @@ goog.db.Cursor.prototype.cursor_ = null;
52 52
53 53 /**
54 54 * Advances the cursor to the next position along its direction. When new data
55   - * is availible, the NEW_DATA event will be fired. If the cursor has reached the
  55 + * is available, the NEW_DATA event will be fired. If the cursor has reached the
56 56 * end of the range it will fire the COMPLETE event. If opt_key is specified it
57 57 * will advance to the key it matches in its direction.
58 58 *
59 59 * This wraps the native #continue method on the underlying object.
60 60 *
61   - * @param {!Object=} opt_key The optional key to advance to.
  61 + * @param {IDBKeyType=} opt_key The optional key to advance to.
62 62 */
63 63 goog.db.Cursor.prototype.next = function(opt_key) {
64 64 if (opt_key) {
@@ -74,7 +74,7 @@ goog.db.Cursor.prototype.next = function(opt_key) {
74 74 * If the cursor points to a value that has just been deleted, a new value is
75 75 * created.
76 76 *
77   - * @param {!Object} value The value to be stored.
  77 + * @param {*} value The value to be stored.
78 78 * @return {!goog.async.Deferred} The resulting deferred request.
79 79 */
80 80 goog.db.Cursor.prototype.update = function(value) {
@@ -130,7 +130,7 @@ goog.db.Cursor.prototype.remove = function() {
130 130
131 131
132 132 /**
133   - * @return {Object} The value for the value at the cursor's position. Undefined
  133 + * @return {*} The value for the value at the cursor's position. Undefined
134 134 * if no current value, or null if value has just been deleted.
135 135 */
136 136 goog.db.Cursor.prototype.getValue = function() {
@@ -139,8 +139,8 @@ goog.db.Cursor.prototype.getValue = function() {
139 139
140 140
141 141 /**
142   - * @return {*} The key for the value at the cursor's position. If the
143   - * cursor is outside its range, this is undefined.
  142 + * @return {IDBKeyType} The key for the value at the cursor's position. If
  143 + * the cursor is outside its range, this is undefined.
144 144 */
145 145 goog.db.Cursor.prototype.getKey = function() {
146 146 return this.cursor_.key;
@@ -164,7 +164,7 @@ goog.db.Cursor.Direction = {
164 164 /**
165 165 * Event types that the cursor can dispatch. COMPLETE events are dispatched when
166 166 * a cursor is depleted of values, a NEW_DATA event if there is new data
167   - * availible, and ERROR if an error occurred.
  167 + * available, and ERROR if an error occurred.
168 168 *
169 169 * @enum {string}
170 170 */
34 closure/goog/db/index.js
@@ -77,17 +77,17 @@ goog.db.Index.prototype.isUnique = function() {
77 77 *
78 78 * @param {string} fn Function name to call on the index to get the request.
79 79 * @param {string} msg Message to give to the error.
80   - * @param {!Object} value Value to look up in the index.
  80 + * @param {IDBKeyType} key The key to look up in the index.
81 81 * @return {!goog.async.Deferred} The resulting deferred object.
82 82 * @private
83 83 */
84   -goog.db.Index.prototype.get_ = function(fn, msg, value) {
  84 +goog.db.Index.prototype.get_ = function(fn, msg, key) {
85 85 var d = new goog.async.Deferred();
86 86 var request;
87 87 try {
88   - request = this.index_[fn](value);
  88 + request = this.index_[fn](key);
89 89 } catch (err) {
90   - msg += ' with value ' + goog.debug.deepExpose(value);
  90 + msg += ' with key ' + goog.debug.deepExpose(key);
91 91 d.errback(goog.db.Error.create(err, msg));
92 92 return d;
93 93 }
@@ -95,7 +95,7 @@ goog.db.Index.prototype.get_ = function(fn, msg, value) {
95 95 d.callback(ev.target.result);
96 96 };
97 97 request.onerror = function(ev) {
98   - msg += ' with value ' + goog.debug.deepExpose(value);
  98 + msg += ' with key ' + goog.debug.deepExpose(key);
99 99 d.errback(new goog.db.Error(
100 100 (/** @type {IDBRequest} */ (ev.target)).errorCode,
101 101 msg));
@@ -106,27 +106,27 @@ goog.db.Index.prototype.get_ = function(fn, msg, value) {
106 106
107 107 /**
108 108 * Fetches a single object from the object store. Even if there are multiple
109   - * objects that match the given value, this method will get only one of them.
  109 + * objects that match the given key, this method will get only one of them.
110 110 *
111   - * @param {!Object} value Value to look up in the index.
112   - * @return {!goog.async.Deferred} The deferred object that matches the value.
  111 + * @param {IDBKeyType} key Key to look up in the index.
  112 + * @return {!goog.async.Deferred} The deferred object for the given record.
113 113 */
114   -goog.db.Index.prototype.get = function(value) {
115   - return this.get_('get', 'getting from index ' + this.getName(), value);
  114 +goog.db.Index.prototype.get = function(key) {
  115 + return this.get_('get', 'getting from index ' + this.getName(), key);
116 116 };
117 117
118 118
119 119 /**
120 120 * Looks up a single object from the object store and gives back the key that
121   - * it's listed under in the object store. Even if there are multiple objects
122   - * that match the given value, this method will only get one of their keys.
  121 + * it's listed under in the object store. Even if there are multiple records
  122 + * that match the given key, this method returns the first.
123 123 *
124   - * @param {!Object} value Value to look up in the index.
125   - * @return {!goog.async.Deferred} The deferred key for the object that matches
126   - * the value.
  124 + * @param {IDBKeyType} key Key to look up in the index.
  125 + * @return {!goog.async.Deferred} The deferred key for the record that matches
  126 + * the key.
127 127 */
128   -goog.db.Index.prototype.getKey = function(value) {
129   - return this.get_('getKey', 'getting key from index ' + this.getName(), value);
  128 +goog.db.Index.prototype.getKey = function(key) {
  129 + return this.get_('getKey', 'getting key from index ' + this.getName(), key);
130 130 };
131 131
132 132

0 comments on commit e5d63e5

Please sign in to comment.
Something went wrong with that request. Please try again.