0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/index4.js

34 lines
709 B
JavaScript
Raw Normal View History

2009-01-27 05:28:26 +01:00
// index4.js
t = db.index4;
t.drop();
t.save( { name : "alleyinsider" ,
instances : [
{ pool : "prod1" } ,
{ pool : "dev1" }
]
} );
t.save( { name : "clusterstock" ,
instances : [
{ pool : "dev1" }
]
} );
// this should fail, not allowed -- we confirm that.
2009-01-27 05:28:26 +01:00
t.ensureIndex( { instances : { pool : 1 } } );
assert( !t.getIndexes().hasNext(), "no indexes should be here yet");
t.ensureIndex( { "instances.pool" : 1 } );
2009-01-27 05:28:26 +01:00
sleep( 10 );
a = t.find( { instances : { pool : "prod1" } } );
assert( a.length() == 1, "len1" );
assert( a[0].name == "alleyinsider", "alley" );
2009-01-27 05:28:26 +01:00
assert(t.validate().valid, "valid" );