I am aware that MongoDB will dynamically create a collection when you attempt to insert a document into a non-existent collection. My question is: How do I set up default options so that the collection has the options I want when it is dynamically created?
Default options for dynamic MongoDB collections
74 Views Asked by DB user10082797 At
2
There are 2 best solutions below
0

I chose to write a wrapper around mongoc_database_get_collection(). There is a little bit of additional overhead for an extra round trip request to the mongo server to see if the collection already exists. If not, the wrapper creates it with the options I want and returns the new collection. If the collection already exists, the wrapper returns the existing collection.
I don't think you can do that. Your options are: