Skip to content

Instantly share code, notes, and snippets.

@TylerBrock
Created July 4, 2012 14:52
Show Gist options
  • Save TylerBrock/3047768 to your computer and use it in GitHub Desktop.
Save TylerBrock/3047768 to your computer and use it in GitHub Desktop.
#!/usr/bin/env mongo --quiet
var m = new Mongo();
var db = m.getDB('test');
var t = db.getCollection('whatever');
t.find( { group:3, 'x.a':1 }, { 'x.$':0 } );
printjson(db.getLastErrorCmd());
assert.eq( 16345, db.getLastErrorCmd().code, "exclusion of positional operator" );
#!/usr/bin/env mongo --quiet
var m = new Mongo();
var db = m.getDB('test');
var t = db.getCollection('bunk');
t.ensureIndex({a:1},{unique: true});
t.insert({a: 1});
t.insert({a: 1});
printjson(db.getLastError());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment