jedireza / mongo-models

:package: Map JavaScript classes to MongoDB collections
MIT License
67 stars 28 forks source link

How to declare a view with mongo-models #32

Closed mike123vn closed 6 years ago

mike123vn commented 6 years ago

Mongodb from version 3.4 supported view feature, so how can i declare a view with Mongo-model

jedireza commented 6 years ago

I have not used views before. Below is just a guess based on what I read from the docs: https://docs.mongodb.com/manual/core/views/

how can i declare a view with Mongo-model

You could probably use the MongoDB.Db we get back from connect(...), and call createView(...) on it.

Once you've created a view it sounds like they'll work just like normal collections, only read only.