Supply models rather than a connected mongoose instance #334
smebberson
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
@smebberson So basically we could just add a new property to linz.init linz.init({
express: app,
models: [connectedModel1, connectedModel2],
mongoose,
options,
passport,
}); Any code that does mongoose.model would need to be updated to use the linz.api.model.get, but that is just a simple search and replace? Would we even need to pass in Mongoose anymore? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was contemplating how in some projects, we access multiple databases.
We generally have one primary database in which we can use Mongoose with, and other non-primary databases in which we don't use Mongoose with but the Mongo DB driver instead.
I was lamenting that it would be great to be able to use Mongoose regardless of the database and to be able to use models store in different databases.
If we updated Linz, to accept a list of models (scoped to one or more connections), it doesn't matter where the database actually lives, Linz could work with models from multiple databases. Linz doesn't really care about the connection, it cares more about the models.
Review https://mongoosejs.com/docs/connections.html#multiple_connections for examples of scoping models specific to connections.
Beta Was this translation helpful? Give feedback.
All reactions