mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
24 lines
468 B
JavaScript
24 lines
468 B
JavaScript
// test sorting, mainly a test ver simple with no index
|
|
|
|
db = connect( "test" );
|
|
t = db.sorrrt2;
|
|
t.drop();
|
|
|
|
t.save({x:1, y:{a:5,b:4}});
|
|
t.save({x:1, y:{a:7,b:3}});
|
|
t.save({x:1, y:{a:2,b:3}});
|
|
t.save({x:1, y:{a:9,b:3}});
|
|
|
|
for( var pass = 0; pass < 2; pass++ ) {
|
|
|
|
var res = t.find().sort({'y.a':1}).toArray();
|
|
assert( res[0].y.a == 2 );
|
|
assert( res[1].y.a == 5 );
|
|
assert( res.length == 4 );
|
|
|
|
t.ensureIndex({"y.a":1});
|
|
|
|
}
|
|
|
|
assert(t.validate().valid);
|