OPTIONS
翻译或纠错本页面

cursor.showDiskLoc()

cursor.showDiskLoc()

Modifies the output of a query by adding a field $diskLoc to matching documents. $diskLoc contains disk location information and has the form:

"$diskLoc": {
  "file": <int>,
  "offset": <int>
}

cursor.showDiskLoc() method is a wrapper around $showDiskLoc.

返回:A modified cursor object that contains documents with appended information that describes the on-disk location of the document.

Example

The following operation appends the showDiskLoc() method to the db.collection.find() method in order to include in the matching documents the disk location information:

db.collection.find( { a: 1 } ).showDiskLoc()

The operation returns the following documents, which includes the $diskLoc field:

{
  "_id" : ObjectId("53908ccb18facd50a75bfbac"),
  "a" : 1,
  "b" : 1,
  "$diskLoc" : { "file" : 0, "offset" : 16195760 }
}
{
   "_id" : ObjectId("53908cd518facd50a75bfbad"),
   "a" : 1,
   "b" : 2,
   "$diskLoc" : { "file" : 0, "offset" : 16195824 }
}

The projection can also access the added field $diskLoc, as in the following example:

db.collection.find( { a: 1 }, { $diskLoc: 1 } ).showDiskLoc()

The operation returns just the _id field and the $diskLoc field in the matching documents:

{
  "_id" : ObjectId("53908ccb18facd50a75bfbac"),
  "$diskLoc" : { "file" : 0, "offset" : 16195760 }
}
{
   "_id" : ObjectId("53908cd518facd50a75bfbad"),
   "$diskLoc" : { "file" : 0, "offset" : 16195824 }
}

参见

$showDiskLoc for related functionality.