Node.js and Mongodb

So i am trying to use Node.js and Mongodb together and the goal is to use Node to get information and store it in a database with Mongodb. SO I have both Node and Mongdb intalled, and I install the Mongodb package with npm, this is the package mongodb recommends. But the problem I am having is that when I try to do

    MongoClient.connect("mongodb://localhost:3000/exampleDb", function(err, db) {
    if(err) { return console.dir(err); }else{
    var collection =db.createCollection('test', function(err, collection) {}); }});

and I go to localhost:port_for express_server, but when the above code is supposed to run I get [Error: failed to connect to [localhost:3000]] in the Node console.Am I supposed to be running mongodb in the background or how is this supposed to work?

when you do

npm install mongodb

you only install a node.js client driver for mongodb.

in order for you script to run, you need to install and start a mongodb server on your box

check server installation procedures on http://docs.mongodb.org/manual/installation/

You seem pretty lost on what mongodb is and how to use it. Mongodb is a noSQL database.

Am I supposed to be running mongodb in the background

Yes, like mysql, you need the server to be installed and running, to use it. You need to do:

  1. mongodb (the db server)
    • install server
    • start the server by typing mongod on terminal
    • check with mongo if it is running and you can connect to it.
  2. node.js (the web server)
    • install node
    • install mongodb package
    • now test your code