0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00
mongodb/jstests/index_check5.js

18 lines
625 B
JavaScript
Raw Normal View History

2009-08-25 17:49:30 +02:00
t = db.index_check5
t.drop();
t.save( { "name" : "Player1" ,
"scores" : [{"level" : 1 , "score" : 100},
{"level" : 2 , "score" : 50}],
"total" : 150 } );
t.save( { "name" : "Player2" ,
"total" : 90 ,
"scores" : [ {"level" : 1 , "score" : 90},
{"level" : 2 , "score" : 0} ]
} );
assert.eq( 2 , t.find( { "scores.level": 2, "scores.score": {$gt:30} } ).itcount() , "A" );
t.ensureIndex( { "scores.level" : 1 , "scores.score" : 1 } );
assert.eq( 1 , t.find( { "scores.level": 2, "scores.score": {$gt:30} } ).itcount() , "B" );