用户登录
用户注册

分享至

MongoDB集合数据操作

  • 作者: 航天飞机制造厂商
  • 来源: 51数据库
  • 2020-08-10

1.查看已有集合

show collections

2.向集合中添加数据

db.runoob.insert({

title:'test',

description:'this is description',

by:'suyanzhu',

url:'http://blog.51cto.com/suyanzhu',

tags:['php','java','mongodb'],

likes:100

})

3.查看集合中数据信息

db.runoob.find()

4.通过定义变量存储数据信息,再添加到runoob集合中

document=({

        "title" : "demo",

        "description" : "this is description",

        "by" : "yansuzhu",

        "url" : "http://blog.51cto.com/suyanzhu",

        "tags" : [

                "php",

                "sql",

                "java"

        ],

        "likes" : "100"

})

db.runoob.insert(document)

//或

db.runoob.save(document)

软件
前端设计
程序设计
Java相关