Permalink
Browse files

Added updateById

  • Loading branch information...
1 parent cab08e1 commit e2d7b5b8158a1321b598a001dcde9d32e464d525 @rauchg rauchg committed Apr 27, 2012
Showing with 23 additions and 0 deletions.
  1. +7 −0 README.md
  2. +16 −0 lib/collection.js
View
@@ -115,6 +115,13 @@ users.id('hexstring') // returns ObjectId
users.id(obj) // returns ObjectId
```
+### Updating
+
+```js
+users.update({}, {}, fn);
+users.updateById('id', {}, fn);
+```
+
### Finding
#### Many
View
@@ -98,6 +98,7 @@ Collection.prototype.indexes = function (fn) {
* @param {Object} search query
* @param {Object} update obj
* @param {Object|String|Array} optional, options or fields
+ * @param {Function} callback
* @return {Promise}
* @api public
*/
@@ -131,6 +132,21 @@ Collection.prototype.update = function (search, update, opts, fn) {
};
/**
+ * update by id helper
+ *
+ * @param {String|Object} object id
+ * @param {Object} update obj
+ * @param {Object|String|Array} optional, options or fields
+ * @param {Function} callback
+ * @return {Promise}
+ * @api public
+ */
+
+Collection.prototype.updateById = function (id, obj, opts, fn) {
+ return this.update({ _id: id }, obj, opts, fn);
+};
+
+/**
* remove
*
* @param {Object} search query

0 comments on commit e2d7b5b

Please sign in to comment.