Skip to content

Commit

Permalink
Implement update and getIndexes
Browse files Browse the repository at this point in the history
  • Loading branch information
saintedlama committed Oct 8, 2015
1 parent 482cb84 commit 1df7336
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,10 @@ Collection.prototype.update = function (query, update, opts, cb) {

cb = cb || noop
var self = this
this._getConnection(function (err, server) {
this._getConnection(function (err, connection) {
if (err) return cb(err)

opts.q = query
opts.u = update
server.update(self._fullColName(), [opts], writeOpts, function (err, res) {
if (err) return cb(err)
cb(null, res.result)
})
connection.collection(self._fullColName()).update(query, update, opts, cb)
})
}

Expand Down Expand Up @@ -204,14 +199,10 @@ Collection.prototype.ensureIndex = function (index, opts, cb) {
}

Collection.prototype.getIndexes = function (cb) {
var cursor = new Cursor({
query: {ns: this._fullColName()},
projection: {},
onserver: this._getConnection,
fullCollectionName: this._dbname + '.system.indexes'
var self = this
this._getConnection(function (err, connection) {
connection.collection(self._fullColName()).indexes(cb)
})

cursor.toArray(cb)
}

Collection.prototype.reIndex = function (cb) {
Expand Down

0 comments on commit 1df7336

Please sign in to comment.