3剑客
Create a Jade template files named "index.jade" in the views directory, with the following content.
html
head
title!= title
body
h1!= message
Then create a route to render the "index.jade" file.
app.get('/',function(req, res){
res.render('index',{ title:'Hey', message:'Hello there!'});})
On making a request to the home page, "index.jade" will be rendered as HTML.
服务端返回网页,不如返回值,客户端判断符合条件,然后跳转本地的html
2.不显示_id字段,显示需要的字段
> db.node_book.find({},{"book_name":1,"author":1,_id:0})
3.查找某个条件的数据
> db.node_book.find({"book_name":"123"},{"book_name":1,"author":1,_id:0})
db.node_book.find({"book_name":"123","author" : "mfy1"},{"book_name":1,"author":1,_id:0})
插入数据
db.node_book.insert({"book_name":"123", "author" : "mfy"})
db.node_book.insert({"book_name":"123", "author" : "mfy1"})
db.node_book.insert({"book_name":"1234", "author" : "mfy1"})
在node的查询代码也可以类似用
4.数据库操作的2个文件放在
文件夹
数据库的配置文件放在根目录下