0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/distinct_array1.js
Eliot Horowitz 876b17b344 make distinct yield safely SERVER-1850
BACKWARDS BREAKING distinct no longer sorts
2010-10-13 16:11:50 -04:00

26 lines
578 B
JavaScript

t = db.distinct_array1;
t.drop();
t.save( { a : [1,2,3] } )
t.save( { a : [2,3,4] } )
t.save( { a : [3,4,5] } )
t.save( { a : 9 } )
res = t.distinct( "a" );
assert.eq( "1,2,3,4,5,9" , res.toString() , "A1" );
//t.drop();
t.save( { a : [{b:"a"}, {b:"d"}] , c : 12 } );
t.save( { a : [{b:"b"}, {b:"d"}] , c : 12 } );
t.save( { a : [{b:"c"}, {b:"e"}] , c : 12 } );
t.save( { a : [{b:"c"}, {b:"f"}] , c : 12 } );
t.save( { a : [] , c : 12 } );
t.save( { a : { b : "z"} , c : 12 } );
res = t.distinct( "a.b" );
res.sort()
assert.eq( "a,b,c,d,e,f,z" , res.toString() , "B1" );