MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Can collation can be used while creating a database in MongoDB?

Hi Team,

Can Collation can be used while creating Database in MongoDB?

Just verified in MongoDB Websites, I am not able to find. If Collation allowed with different language, Kindly assist with sample/Syntax for the same.

Regards,
Jay

You may find the following helpful.

https://docs.mongodb.com/manual/reference/collation/

Collation can currently only be specified for a collection, view, index, or operation that supports collation.

Databases are created implicitly when you first store data for that database. As at MongoDB 4.2, there is no API to set database-level defaults such as collation.

Collections are typically also created implicitly, but an empty collection can be created with specific options such as collation and compression. See the db.createCollection() documentation for a reference on collection options using the mongo shell. You can also pass equivalent options using your MongoDB driver.

There is also a relevant feature request you can watch/upvote in the MongoDB issue tracker: SERVER-28362: Default collation for database.

Regards,
Stennie