Files
mongo/jstests/core/exists5.js
Randolph Tan 5595b94560 SERVER-12127 migrate js tests to jscore suite when not related to writes
Moved test jstest/[a-i].js -> jstests/core/ and made changes to comply with write command api
2014-02-28 16:26:33 -05:00

34 lines
1.2 KiB
JavaScript

// Test some $not/$exists cases.
t = db.jstests_exists5;
t.drop();
t.save( {a:1} );
assert.eq( 1, t.count( {'a.b':{$exists:false}} ) );
assert.eq( 1, t.count( {'a.b':{$not:{$exists:true}}} ) );
assert.eq( 1, t.count( {'c.d':{$not:{$exists:true}}} ) );
assert.eq( 0, t.count( {'a.b':{$exists:true}} ) );
assert.eq( 0, t.count( {'a.b':{$not:{$exists:false}}} ) );
assert.eq( 0, t.count( {'c.d':{$not:{$exists:false}}} ) );
t.drop();
t.save( {a:{b:1}} );
assert.eq( 1, t.count( {'a.b':{$exists:true}} ) );
assert.eq( 1, t.count( {'a.b':{$not:{$exists:false}}} ) );
assert.eq( 0, t.count( {'a.b':{$exists:false}} ) );
assert.eq( 0, t.count( {'a.b':{$not:{$exists:true}}} ) );
t.drop();
t.save( {a:[1]} );
assert.eq( 1, t.count( {'a.b':{$exists:false}} ) );
assert.eq( 1, t.count( {'a.b':{$not:{$exists:true}}} ) );
assert.eq( 0, t.count( {'a.b':{$exists:true}} ) );
assert.eq( 0, t.count( {'a.b':{$not:{$exists:false}}} ) );
t.drop();
t.save( {a:[{b:1}]} );
assert.eq( 1, t.count( {'a.b':{$exists:true}} ) );
assert.eq( 1, t.count( {'a.b':{$not:{$exists:false}}} ) );
assert.eq( 0, t.count( {'a.b':{$exists:false}} ) );
assert.eq( 0, t.count( {'a.b':{$not:{$exists:true}}} ) );