[SERVER-16813] Shell helper to get a single collection's options document Created: 12/Jan/15  Updated: 13/Jan/17  Resolved: 13/Jan/17

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 2.8.0-rc4
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Kyle Erf Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Won't Fix Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

For writing jstests or general deployment debugging, it would be useful to have easy access to collection metadata. Previously, this data was available by querying the system.namespaces collection, but that is no longer supported with new storage engines. It would be very helpful to have a shell helper to wrap the listCollections command and return just the collection object for a single collection.

This could be implemented as a db method, i.e.

db.collectionOptions("myCollection")

or added to the collection prototype

db.myCollection.options()



 Comments   
Comment by Justin Cohler [ 13/Jan/17 ]

We are not focusing on new shell features at this point.

Comment by Matt Kangas [ 21/Jan/15 ]

Talking to a 2.6 server:

MongoDB shell version: 2.8.0-rc6-pre-
> db.serverBuildInfo().version
2.6.3
> db.foo.exists()
{ "name" : "test.foo" }

Talking to a 2.8 server with storageEngine=mmapv1:

MongoDB shell version: 2.8.0-rc6-pre-
> db.serverBuildInfo().version
2.8.0-rc6-pre-
> db.foo.exists()
> db.foo.exists()
{ "name" : "foo", "options" : { "flags" : 1 } }

This was introduced in SERVER-13635. DBCollection.prototype.exists now uses the listCollections command if it exists, otherwise it falls back to a findOne on system.namespaces.

Aliasing the new behavior (only) as an options() method seems reasonable.

Comment by Kyle Erf [ 12/Jan/15 ]

Looks like it does, thanks! That said, the name of that helper doesn't really explain the full scope of what it returns. We may want to consider aliasing it as options() or info() or something as well.

Comment by J Rassi [ 12/Jan/15 ]

Does the db.foo.exists() helper provide the functionality you're looking for?

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