I am using Mongoose in my node.js app to model two collections in the database, which it will read and write. There are two more collections which are going to be read only from my app (the model for these collections is being maintained in another app, which will write to them).
If I need to access the two read-only collections using mongoose, then I will have to maintain a schema within this app as well. I would rather not do this as the schema will be maintained twice and could lead to inconsistency later on.
The default connection in Mongoose can be created by
Mongoose.connect(dbPath)
Given a dbPath (e.g. mongodb://localhost/dbname), how can I use the Mongoose default connection to read from a collection whose schema/model is not being maintained by my app? Or will I have to use the native MongoDB driver for the same?
Aucun commentaire:
Enregistrer un commentaire