how to access various mongo databases with node

49 views
Skip to first unread message

Roland Bole

unread,
May 25, 2015, 8:47:36 AM5/25/15
to nod...@googlegroups.com

I need some guideline with this question.

I try to build an node express REST api which has to deal with various mongoDB databases on the same mongoDB server.

What is the right approach to do this?

The sequence could be:

  • app starts
  • connect to the mongoDB Server
  • use the right express route
  • check which database is needed
  • finally query the correct data
  • connection to the database is still open

OR

  • use the right express route
  • connect to the mongoDB Server
  • check which database is needed
  • query the data
  • close the DB connection

AND how can I do this with mongo-native driver, not mongoose?

Thanks for any help.

Oleg Verych

unread,
May 26, 2015, 8:23:07 AM5/26/15
to nod...@googlegroups.com
Hi, Roland

I need some guideline with this question.

I try to build an node express REST api which has to deal with various mongoDB databases on the same mongoDB server.

What is the right approach to do this?

[...]

AND how can I do this with mongo-native driver, not mongoose?

Abramovick

unread,
May 26, 2015, 3:42:58 PM5/26/15
to nod...@googlegroups.com
The best native mongodb driver wrapper i've been using would be mongojs. https://github.com/mafintosh/mongojs
Tutorials on how to use it in relation to the bullet point you raised: http://howtonode.org/node-js-and-mongodb-getting-started-with-mongojs
Reply all
Reply to author
Forward
0 new messages