Automattic / mongoose

MongoDB object modeling designed to work in an asynchronous environment.
https://mongoosejs.com
MIT License
26.96k stars 3.84k forks source link

Document that autoCreate defaults to true and is OK for production #11205

Closed joebowbeer closed 2 years ago

joebowbeer commented 2 years ago

Aside from the migration guide, which says that autoCreate now defaults to true except in some secondary cases, the Schema Options documentation has not been updated.

https://mongoosejs.com/docs/guide.html#autoCreate

Unfortunately, createCollection() cannot change an existing collection. For example, if you add capped: 1024 to your schema and the existing collection is not capped, createCollection() will throw an error. Generally, autoCreate should be false for production environments.

Unlike autoIndex, autoCreate is false by default. You can change this default by setting mongoose.set('autoCreate', true);

From:

So documentation should mirror that case then and be not so strict on not using autoCreate in prod :)

Originally posted by @deser in https://github.com/Automattic/mongoose/issues/8814#issuecomment-766811295

vkarpov15 commented 2 years ago

This was fixed with #11116 with https://github.com/Automattic/mongoose/commit/b0edb077729a747b008c1d7b55294241d5246260