New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way we can handle views with mongoose !? #5694
Comments
Not sure what you mean by handling views. What's the plugin you're talking about? Once a view is created, as far as mongoose is concerned it is just a read-only collection, so as long as you have a schema in mongoose you can query the view as you would any normal collection. |
I meant how can i create read only collection with mongoose, that is allowed by mongodb |
|
so we can use createCollection to create a view. and redirect our model to use that view ? |
@alzalabany you would create 2 separate models, one that points to the allData collection and one that points to the activeData view. Use the third param to mongoose.model to specify the collection name http://mongoosejs.com/docs/api.html#mongoose_Mongoose-model |
It would be great if there was some kind of code example of this. |
docs(models): add section on MongoDB Views
feature
What is the current behavior?
currently there is a plugin, but that only selects few fields, and doesn't work on multiple models
What is the expected behavior?
https://docs.mongodb.com/manual/reference/method/db.createView/#db.createView
using mongoDB 3.4
The text was updated successfully, but these errors were encountered: