getDefaultCollectionOptions

On this page

Returns the defaults that are used when a collection is created implicitly by a write command for the current/specified database. These defaults can be set using the setDefaultCollectionOptions command.

Syntax

db.runCommand({ getDefaultCollectionOptions: 1 });

Example

The following command returns the defaults set for the current database:

db.runCommand({ getDefaultCollectionOptions: 1 });
{ value: { shardKey: { _id: 1 } }, ok: 1 }

Last modified: May 10, 2023

Was this article helpful?