3 ms·
> While it’s in our best interests to keep similar documents restricted to certain collections, there’s no kind of constraint that enforces this. However, if y
by petetnt 10y ago
> While it’s in our best interests to keep similar documents restricted to certain collections, there’s no kind of constraint that enforces this.
However, if you need such a thing, there's always things such as Mongoose[1] that can do this trivially for you.
[1] https://github.com/Automattic/mongoose https://github.com/Automattic/mongoose
- elmigranto 10y agoBut you still can insert non-consitent data into the database with CLI, or otherwise. And `default` values defined inside Mongoose is no good when filtering or searching documents. There are plenty more problems with emulating schema in app code (Mongoose or anything else), so it's not that trivial.