[SERVER-15359] Provide "id" of collection Created: 23/Sep/14  Updated: 20/Oct/17  Resolved: 22/Mar/17

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 3.5.5

Type: Improvement Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Geert Bosch
Resolution: Done Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
is documented by DOCS-10061 Docs for SERVER-15359: Provide "id" o... Closed
Related
related to SERVER-4941 collection rename may not replicate /... Closed
Backwards Compatibility: Fully Compatible
Sprint: Storage 2017-03-27
Participants:

 Description   

It would be very helpful for clients, like replication or sharding, to track collection via a unique id which doesn't change during a rename or restarts. The "id" should be the same across replicas in a set or shards in a sharded cluster. Note: There is already an _id in sharding metadata for a collection but that is not exposed.

Here is an example of output from listCollections with an "id":

> db.runCommand("listCollections")
{
	"collections" : [
		{
			"id" : NumberLong("70368744177664"),
			"name" : "system.indexes",
			"options" : {}
		}
	],
	"ok" : 1
}



 Comments   
Comment by Geert Bosch [ 22/Mar/17 ]

This is now implemented in MongoDB 3.6.

db.getCollectionInfos()
[
	{
		"name" : "x",
		"type" : "collection",
		"options" : {
			
		},
		"info" : {
			"readOnly" : false,
			"uuid" : UUID("c74fc314-ffce-4223-90c0-4849a4ac10b5")
		},
		"idIndex" : {
			"v" : 2,
			"key" : {
				"_id" : 1
			},
			"name" : "_id_",
			"ns" : "mydb.x"
		}
	}
]

Generated at Thu Feb 08 03:37:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.