diff options
author | Antonin Kral <a.kral@bobek.cz> | 2011-03-17 00:05:43 +0100 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2011-03-17 00:05:43 +0100 |
commit | 582fc32574a3b158c81e49cb00e6ae59205e66ba (patch) | |
tree | ac64a3243e0d2121709f685695247052858115c8 /jstests/distinct_index2.js | |
parent | 2761bffa96595ac1698d86bbc2e95ebb0d4d6e93 (diff) | |
download | mongodb-582fc32574a3b158c81e49cb00e6ae59205e66ba.tar.gz |
Imported Upstream version 1.8.0
Diffstat (limited to 'jstests/distinct_index2.js')
-rw-r--r-- | jstests/distinct_index2.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/jstests/distinct_index2.js b/jstests/distinct_index2.js new file mode 100644 index 0000000..2ba65f9 --- /dev/null +++ b/jstests/distinct_index2.js @@ -0,0 +1,35 @@ +t = db.distinct_index2; +t.drop(); + +t.ensureIndex( { a : 1 , b : 1 } ) +t.ensureIndex( { c : 1 } ) + +function x(){ + return Math.floor( Math.random() * 10 ); +} + +for ( i=0; i<2000; i++ ){ + t.insert( { a : x() , b : x() , c : x() } ) +} + +correct = [] +for ( i=0; i<10; i++ ) + correct.push( i ) + +function check( field ){ + res = t.distinct( field ) + res = res.sort() + assert.eq( correct , res , "check: " + field ); + + if ( field != "a" ){ + res = t.distinct( field , { a : 1 } ) + res = res.sort() + assert.eq( correct , res , "check 2: " + field ); + } +} + +check( "a" ) +check( "b" ) +check( "c" ) + + |