MongoDB and NodeJS demo with MongooseJS
CoffeeScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
create.coffee
find.coffee
models.coffee
package.json
query.coffee
readme.md
remove.coffee
songs.json
stream.coffee

readme.md

MongoDB in NodeJS with Mongoose

MongoDB and NodeJS? Match made in heaven!

Resources:

What we're covering

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

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!