1

I would like to use mongo js and mongoose in the same app.I require mongo js as i don't want write schema for a specific functionality of the app as it includes nested and complex data.I tried mongoose but that just makes it more difficult.With mongojs I could directly write mongodb queries and execute.Whereas for other functionalities like validation and simple schema,mongoose would be better so can I use both. I would be connecting to db in the controller and not app.js,although I know I would require to connect every time,but I think thats the only way.

Mohammed Gadiwala
  • 1,923
  • 2
  • 18
  • 26

2 Answers2

1

Yes, we're actually using multiple drivers, in a production application. We need connections to multiple databases, and mongoose is only able to connect to one DB. So we use MongoDB for the connections to the secondary databases. It should be the same using MongoJS instead.

Antoine
  • 5,055
  • 11
  • 54
  • 82
0

Yes, in fact I do this currently for a few reasons. Mongoose carries a bit of overhead with its serialization and I ran into issues with it handling a large amount of operations at scale. When we need to do heavy lifting with our collections: inserting/updating 10s of millions of times, I prefer to use something a bit closer to the metal and we use mongojs for that.

Jake Dempsey
  • 6,264
  • 1
  • 30
  • 25