You are on page 1of 2

mongodb

db.articles.insert({title:"Hello World"})
db.articles.find()
install node.js
node application.js
npm install <name>
npm install -g <package name>
npm update <package name>
npm install express --save
require
export
module
module.export
connect for middleware flow -- dispatcher object, logging, and res.end()
to register middleware app.use to be called
next() determines the next middleware to call
mounting connect middleware
mongo db commands:
default test database
mongo
use mean
show dbs
db.posts.insert({"title":"First Poost","user":"chandra"})
db.posts.insert({"title":"Second Post","user":"ran"})
db.posts.find()
show collections
db.posts.update({
"user": "chan1"
},{
"title": "Seeccc",
"user": "test"
},{
upsert: true
})
db.posts.save({"title":"First Poost","user":"chandra"})
db.posts.find({"user":"chandra"})

db.posts.find({"user":{ $in:["chandra","test"]}})
db.posts.find({$or:[{"user":"chandra"},{"user":"ran1"}]})
db.posts.drop()
db.posts.update({
"user": "chandra"
},{
$set:{
"title":"this is coool"
}
},{
multi: true
})
db.posts.save({
});
db.posts.remove()
db.posts.remove({"user": "chandra"},true)
exports.list = function(req,res,next){
User.find({},'username email firstName',{
skip:2,
limit:2
},function(err,users){
if(err){
return next(err);
}
else {
res.json(users);
}
});
};

You might also like