diff options
author | David Storch <david.storch@10gen.com> | 2015-04-08 14:41:05 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2015-04-09 16:43:49 -0400 |
commit | 374438c9134e6e31322b05c8ab4c5967d97bf3eb (patch) | |
tree | 07e626f2c197b75e2e97c93b7bb16ca8d73116ef /jstests/core/show_record_id.js | |
parent | 8f7ad88b463c5dea8bca8d8e0626fa80f35e3a47 (diff) | |
download | mongo-374438c9134e6e31322b05c8ab4c5967d97bf3eb.tar.gz |
SERVER-17718 deprecate showDiskLoc()
The showDiskLoc() shell helper is now an alias for showRecordId(). The server still
accepts $showDiskLoc for OP_QUERY style find operations. For find command, the showDiskLoc
argument has been renamed to showRecordId.
Also renames the $diskLoc field returned in the resulting documents to $recordId. Unlike
$diskLoc, the $recordId field reports a single 64 bit integer rather than separately reporting the
high-order 32 bits and low-order 32 bits, which have MMAPv1-specific meaning of file and offset.
Diffstat (limited to 'jstests/core/show_record_id.js')
-rw-r--r-- | jstests/core/show_record_id.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/jstests/core/show_record_id.js b/jstests/core/show_record_id.js new file mode 100644 index 00000000000..d28cf6560e6 --- /dev/null +++ b/jstests/core/show_record_id.js @@ -0,0 +1,34 @@ +// 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()._addSpecial("$showDiskLoc" , true).toArray() ); +checkResults( t.find().showRecordId().toArray() ); + +// Check query and get more. +t.save( {} ); +t.save( {} ); +checkResults( t.find().batchSize( 2 )._addSpecial("$showDiskLoc" , true).toArray() ); +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 } )._addSpecial("$showDiskLoc" , true).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 } )._addSpecial("$showDiskLoc", true).toArray() ); +checkResults( t.find( { _id: 0 } ).showRecordId().toArray() ); |