Files
mongo/jstests/core/show_record_id.js
David Storch ffdb57ed20 SERVER-17544 remove $-prefixed find options from jstests and comments
Since the format for passing these options is different for the find command, these options should be specified
using the DBQuery helpers.
2015-07-23 19:51:04 -04:00

31 lines
768 B
JavaScript

// Sanity check for the showRecordId option.
var t = db.show_record_id;
t.drop();
function checkResults( arr ) {
for( i in arr ) {
a = arr[ i ];
assert( a['$recordId'] );
}
}
// Check query.
t.save( {} );
checkResults( t.find().showRecordId().toArray() );
// Check query and get more.
t.save( {} );
t.save( {} );
checkResults( t.find().batchSize( 2 ).showRecordId().toArray() );
// Check with a covered index.
t.ensureIndex( { a:1 } );
checkResults( t.find( {}, { _id:0, a:1 } ).hint( { a:1 } ).showRecordId().toArray() );
checkResults( t.find( {}, { _id:0, a:1 } ).hint( { a:1 } ).showRecordId().toArray() );
// Check with an idhack query.
t.drop();
t.save({_id: 0, a: 1});
checkResults( t.find( { _id: 0 } ).showRecordId().toArray() );