Thursday, 14 February 2019

Need help understanding how Mongoose works beneath the hood

Basically, what I'm trying to understand is why it's possible to create the MongoDB database connection with mongoose.connect() in one file, then use the model.save() function in another file without having to import the same instance of mongoose (the one that created the database connection) from the first file. As in, how does model.save() access the database connection? Is there a variable with global scope that Mongo creates, that can be accessed from anywhere within your Node application's file structure, after calling require('mongoose') somewhere in the application?

Submitted February 14, 2019 at 10:54AM by EuroSparkle

No comments:

Post a Comment