nodejs and mongodb

Connect to MongoDb in NodeJS (latest version 4.0) with Mongoose

Setup project structure

NodeJS with MongoDb

packages.json

app.js

node app.js

nodejs helloworld

Create new model call Book.js in models folder

nodejs in mongodb

Book.js

You don’t need a id, because by default mongo will add a _id field for identity

Add some code to app.js. It show some query to MongoDb

nodejs with mongodb

nodejs with mongodb

Download example code

More examples at: https://gist.github.com/arvis/3357699

find more queries at: http://mongoosejs.com/docs/2.7.x/docs/query.html

NodeJS: Manipulate MongoDb with Mongoose

Category: DatabaseJavascriptMongoDbNodeJSPrograming
0
899 views

Join the discussion

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.