mongoose
mongoose copied to clipboard
Option to not create the collection when compiling model
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Placing null
in the collectionName argument should make it not create a collection for that model
Motivation
No response
Example
mongoose.model(name, schema, null)
This is an interesting idea. What is the use case for this behavior? Is this mostly a way to create subdocuments?
This is an interesting idea. What is the use case for this behavior? Is this mostly a way to create subdocuments?
Lets you have a model that represents a log, you have multiple websites you want to have logs off. So to improve performance, you want to have the websites' logs in a different collection from each other.
Got it?
That's an interesting idea. How would you change the log model's collection?
That's an interesting idea. How would you change the log model's collection?
Current way of doing it (tmk) is getting the mongo connection and inserting the document (const document = new Model()
) into a collection
Could add an option in document.save
to set the collection.