Files
mongo/jstests/core/index1.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

25 lines
574 B
JavaScript

t = db.embeddedIndexTest;
t.remove( {} );
o = { name : "foo" , z : { a : 17 , b : 4} };
t.save( o );
assert( t.findOne().z.a == 17 );
assert( t.findOne( { z : { a : 17 } } ) == null);
t.ensureIndex( { "z.a" : 1 } );
assert( t.findOne().z.a == 17 );
assert( t.findOne( { z : { a : 17 } } ) == null);
o = { name : "bar" , z : { a : 18 } };
t.save( o );
assert.eq.automsg( "2", "t.find().length()" );
assert.eq.automsg( "2", "t.find().sort( { 'z.a' : 1 } ).length()" );
assert.eq.automsg( "2", "t.find().sort( { 'z.a' : -1 } ).length()" );
assert(t.validate().valid);