node.js database

47,906

Solution 1

I'm the developer of the mongodb driver for node.js. I'm using mongodb for my own projects and have been very happy with the performance of mongodb.

Mongodb driver for node.js

(Shameless plug) Feel free to ask any questions about the driver at

Google group for the mongodb driver

or here at Stackoverflow

Have fun with node.js. I absolutely love the platform :D

Solution 2

Although your choice very much depends on the features you are going for, I really appreciate CouchDB for its native JavaScript environment. Both data and views are written in JavaScript so it fits very well to node.js in my opinion.

There are also different client libraries available, some are rather low level, other really very abstracted.

But as I said, you should also think about the features that you require for your database.

Solution 3

Redis is a popular choice. What you're after is a database driver that doesn't block.

The databases you listed are all very different. Redis takes the idea of key-value storages and runs with it, adding a variety of data types and ways of querying data. People often note that redis scales down very well too; meaning that it has very low overhead despite having the ability to perform.

Here is a list of available database modules: http://wiki.github.com/ry/node/modules#database

Solution 4

I really like CouchDB. It's a bit of a learning curve, but views are really powerful once you understand how to use them. There is a module called cradle on github and npm that is really easy to work with. I haven't been able to test how fast it is, but it is really flexible (you can access your data in a browser too if you'd like).

The major issue here is which database design makes sense for your application. Do you have data that is largely key-value in nature? If so, use Redis. Do you have data where not all documents necessarily have the same fields? If so, use a NoSQL database like CouchDB.

The next worse thing to using a blocking database is using the wrong database for your data. CouchDB is managed by Apache, so you know that it's good quality, but it doesn't make sense to use it if your data would make more sense in an SQL table or a simple key-value store.

Think of your use case. Will you be more likely to want to do a full-text search, just get data by key, or get ranges of documents that have similar attributes?

Solution 5

Might want to check out Persistence, high level persistance/database system for node.js.

from thechangelog.com:

Persistence is a project to allow a high level API for persisting data between process runs. The goal is to support backends that are easy to use, powerful, flexible, or all of the above if possible.

Supported databases include:

  • PostgreSQL - An enterprise level relational database. The driver is implemented in pure JavaScript and communicates over TCP using the PostgreSQL wire protocol.
  • Sqlite3 - A simple, fast, server-less relational database. This driver is a wrapper around the command-line sqlite3 program. It requires sqlite3 to be in the path. The communication is extremely fast, but types aren’t very precise. There are only strings and nulls returned.
  • MongoDB - A scalable, high-performance, open source, schema-free, document-oriented database. This driver also implements the wire protocol in JavaScript and communicated with the server over TCP.
  • JSON-DB - A homegrown system schema-free, document-oriented database that uses simple flat files containing JSON objects. This has no requirements at all except node and a filesystem. Performance is to be determined once it’s implemented fully.
Share:
47,906

Related videos on Youtube

Justin
Author by

Justin

Updated on July 08, 2022

Comments

  • Justin
    Justin almost 2 years

    I'm looking for a database to pair with a node.js app. I'm assuming a json/nosql db would be preferable to a relational DB [I can do without any json/sql impedance mismatch]. I'm considering:

    • couchdb
    • mongodb
    • redis

    Anyone have any views / war stories re compatiability/deployability of the above with node.js? Any clear favorites?

    • Samyak Bhuta
      Samyak Bhuta over 12 years
      I think it would be helpful to answer the question if even broader requirements are mentioned. Each DB has its own pros, cons and speciality. Let us know the specs !
  • lacker
    lacker over 13 years
    Persistence hasn't been updated since March 2010 and is on release 0.0.4, so it seems like it might have been abandoned.
  • AppleGrew
    AppleGrew about 13 years
    Yes Redis is great but it seems we can store binary data but cannot retrieve that! Atleast I couldn't find any Redis command for binary data.
  • DanielS
    DanielS over 12 years
    Really? I used to store binary data (using Node's Buffer class) and it worked fine. What version of Redis/Node?
  • Matt Ranney
    Matt Ranney over 12 years
    By default, node_redis will return JavaScript strings for all commands. To get buffers instead, create a client with createClient(port, host, { return_buffers: true });
  • taxilian
    taxilian over 12 years
    also look at mongoose, which is a fairly nice ORM that builds on top of / uses the mongodb driver for node.js
  • hayesgm
    hayesgm over 12 years
    @MattRanney, You save just saved me hours more of digging! I didn't see this anywhere in the node-Redis docs and literally time-sunk 5 hours. My appreciation is without limit in this moment.
  • Samyak Bhuta
    Samyak Bhuta over 12 years
    We are using Node.js + MongoDB for quite some time and it is going great. And full kudos to @christkv, the driver is rock solid and will not fail you. We have deployed the node.js/express.js + mongodb on EC2 with ease. Also, note that we are not using Mongoose. Talking about challenges (assuming you are already good at Node), you need to be good at Mongo way of doing the things (querying and aggregation ) for any serious application or service development. Learning how Mongo is different from other DBs would be really you should to first if you are still in evaluation stages.
  • christkv
    christkv over 12 years
    from what I understand some really cool features are coming down the line to speed up aggregation in mongodb. One of them is native aggregation functions. slideshare.net/cwestin63/mongodb-aggregation-mongosf-may-201‌​1 and also a possible switch to v8 instead of spidermonkey for the javascript engine which will allow each map-reduce command to run in it's own thread (bye bye singlethreaded map-reduce)
  • PirateApp
    PirateApp over 6 years
    well all sounds good in theory but take a practical example , you have a JSON API that you query every 20 seconds which returns an array, you wanna be able to cache this, would you still go with Redis? also gotta do a fuzzy search through this array