22

I've heard much good about nodejs and writting client-server application with it. But I can't get, for example, when developing IM client-server application, how nodejs server script is supposed to talk to database server to actually store it's data? Or may be I miss something and nodejs server scripts are not supposed to do that? If so, please, push me to correct direction.

I've noticed DBSLayer http://code.nytimes.com/projects/dbslayer/wiki, but it looks like it's still in beta.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156

2 Answers2

41

You need to grab a module that handles the communication to the database you want. See here for a list of modules for node.js. Popular databases that work well with node.js are MongoDB, CouchDB and Redis.

stagas
  • 4,607
  • 3
  • 28
  • 28
  • Couchdb is an excellent choice for use with node. There are some great modules on github for interfacing with the database – jdc0589 Aug 22 '10 at 01:41
1

As stagas says, you can use a module that handles communication if you want to use an external database.

If you want an internal (=embedded) database, you can use one written in javascript you can require like any other module such as NeDB or nStore. They are easier to use and useful if your webapp doesn't need to handle a lot of concurrent connections (e.g. a tool you make for yourself or a small team), or if you write a desktop app using Node Webkit

Louis Chatriot
  • 2,031
  • 2
  • 15
  • 13