mongodb基础学习

    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个文件放在 文件夹
数据库的配置文件放在根目录下
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值