Skip to content

Instantly share code, notes, and snippets.

@aheckmann
Created September 4, 2013 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aheckmann/6441067 to your computer and use it in GitHub Desktop.
Save aheckmann/6441067 to your computer and use it in GitHub Desktop.
var assert = require('assert')
var uri = 'mongodb://localhost/findAndModifyBug';
var mongo = require('mongodb')
console.log('driver version: %s', mongo.version);
mongo.connect(uri, function (err, db) {
if (err) throw err;
console.log('connected');
var c = db.collection('test');
c.insert({ query: 'some texts' }, function (err) {
if (err) return done(err);
console.log('created sucessfully');
c.findAndModify({ query: 'some texts' }, [], { $inc: { views: 1}}, { new: true, upsert: true }, function (err, doc) {
console.log(err);
done()
})
})
function done (err) {
if (err) console.error(err);
db.dropDatabase(function(){
db.close();
})
}
})
driver version: 1.3.19
connected
created sucessfully
{ [MongoError: exception: assertion src/mongo/db/../bson/bsonobjbuilder.h:92]
name: 'MongoError',
lastErrorObject: { updatedExisting: true, n: 1, connectionId: 77, err: null, ok: 1 },
errmsg: 'exception: assertion src/mongo/db/../bson/bsonobjbuilder.h:92',
code: 0,
ok: 0 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment