Skip to content
MongoDB and NodeJS demo with MongooseJS
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

MongoDB in NodeJS with Mongoose

MongoDB and NodeJS? Match made in heaven!


What we're covering

  • How to connect to the DB and create schemas (
  • How to create new documents (
  • How to use the Model.find() function, similar to the MongoDB shell commands (
  • How to create and use the Query object by doing query = Model.find({}), then specifying filters and options (
  • How to use the function for streaming data from MongoDB (
  • How to remove documents (

How To Play

Mock Data

Included here is some mock data under the songs.json. To import the data into your database, do:

mongoimport -d test -c songs --type json songs.json

Setting up NodeJS and Mongoose

To start playing around with the files here, make sure you have NodeJS installed.

After that you need to install the required packages. (Which is just Mongoose, really)

Clone this repo, then when you're inside, do:

npm install

Also, you'll need CoffeeScript to run the .coffee files. To install CoffeeScript, do:

npm install coffee-script -g

Once you're done, run the files by doing:

coffee create
coffee find
coffee query
coffee stream
coffee remove

Have fun!

Something went wrong with that request. Please try again.