# setDefaultCollectionOptions

Sets the defaults that are used when a collection is created implicitly by a write command for the current database. All the options supported by the [createCollection](https://docs.singlestore.com/cloud/reference/singlestore-kai/singlestore-extension-commands/createcollection.md) command can be modified using `setDefaultCollectionOptions`.

## Syntax

```mongodb
db.runCommand({
  setDefaultCollectionOptions: 1
  value : <document>|<null>
})
```

| Field   | Type     | Description                                                                                                          |
| ------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `value` | Document | Specifies the options to set. When set to`null`, collection options are reset to the defaults set for new databases. |

## Example

The following example sets default collection options for the current database:

```mongodb
db.runCommand({
  setDefaultCollectionOptions: 1,
  value: { rowstore: true, shardKey: { _id: 1 } },
});
```

To update only one option from the defaults while leaving others unchanged, you may need to run multiple commands. Here's an example:

```mongodb
var options = db.runCommand({ getDefaultCollectionOptions: 1 }).value;
options.shardKey = { Code: 1 };
db.runCommand({ setDefaultCollectionOptions: 1, value: options });
```

***

Modified at: May 15, 2023

Source: [/cloud/reference/singlestore-kai/singlestore-extension-commands/setdefaultcollectionoptions/](https://docs.singlestore.com/cloud/reference/singlestore-kai/singlestore-extension-commands/setdefaultcollectionoptions/)

(An index of the documentation is available at /llms.txt)
