0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00
mongodb/jstests/sort2.js
2009-01-31 17:22:22 -05:00

23 lines
444 B
JavaScript

// test sorting, mainly a test ver simple with no index
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);