[SERVER-26513] listCollections output should include _id index spec as idIndex Created: 07/Oct/16  Updated: 17/May/19  Resolved: 18/Oct/16

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 3.4.0-rc1

Type: Task Priority: Blocker - P1
Reporter: Tess Avitabile (Inactive) Assignee: Tess Avitabile (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-26599 Master-slave initial sync should use ... Closed
Documented
is documented by DOCS-9480 Docs for SERVER-26513: listCollection... Closed
Related
related to PHPLIB-226 Implement ArrayAccess for CollectionI... Closed
Backwards Compatibility: Minor Change
Sprint: Query 2016-10-31
Participants:

 Description   

> db.runCommand({listCollections: 1})
{
	"cursor" : {
		"id" : NumberLong(0),
		"ns" : "test.$cmd.listCollections",
		"firstBatch" : [
			{
				"name" : "c",
				"type" : "collection",
				"options" : {
					
				},
				"info" : {
					"readOnly" : false
				}
				“idIndex”: {
					"v" : 1,
					"key" : {
						"_id" : 1
						},
					"name" : "_id_",
					"ns" : "test.c"
				}
			},
]	
}
}

The idIndex field will not be included for views or collections without an _id index.



 Comments   
Comment by Tess Avitabile (Inactive) [ 21/Oct/16 ]

steve.briskin, we were considering: would it have made more sense for us to include the idIndex field as part of the options field, so that you could simply append all of the options to the create command, instead of having to treat idIndex specially? It wouldn't be too late for us to change this.

Comment by Tess Avitabile (Inactive) [ 18/Oct/16 ]

This change adds a field idIndex to the listCollections output for any collection with an _id index. The idIndex field contains the index spec for the _id index.

Comment by Githook User [ 18/Oct/16 ]

Author:

{u'username': u'tessavitabile', u'name': u'Tess Avitabile', u'email': u'tess.avitabile@mongodb.com'}

Message: SERVER-26513 listCollections output should include _id index spec as idIndex
Branch: master
https://github.com/mongodb/mongo/commit/1a940972e9e1ed78adfff6f31c2907a2c860d17c

Comment by Tess Avitabile (Inactive) [ 17/Oct/16 ]

steve.briskin, we were wondering whether this ticket is necessary for backup, since you can also get the _id index spec by calling getIndexes. It is somewhat undesirable for the server to add the _id index spec to the listCollections output, since this may require drivers changes, and we would need to decide on the correct output for views and collections with no _id index. Would it work for you to call getIndexes to get the _id index spec?

Comment by Tess Avitabile (Inactive) [ 12/Oct/16 ]

Adding the _id index spec to the listCollections output causes the dbhashes to differ for master-slave configurations, because the _id indexes can have different versions.

Generated at Thu Feb 08 04:12:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.