Mongodb基础

2019-04-06  本文已影响0人  ImClive

一、简介

二、功能

三、基础知识

> use test
switched to db test
> post
{ "a" : 1, "b" : 2, "c" : "3" }
> db.blog.insert(post)
WriteResult({ "nInserted" : 1 })
> db.blog.find()
{ "_id" : ObjectId("5ca812e664957f8577f08112"), "a" : 1, "b" : 2, "c" : "3" }
> db.blog.findOne()

        "_id" : ObjectId("5ca812e664957f8577f08112"),
        "a" : 1,
        "b" : 2,
        "c" : "3"
}

> post.d = [{"1":1}]
[ { "1" : 1 } ]
> post
{ "a" : 1, "b" : 2, "c" : "3", "d" : [ { "1" : 1 } ] }
> db.blog.update({a:1}, post)
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

> db.blog.remove({a:1})
WriteResult({ "nRemoved" : 2 })
> db.blog.find()
上一篇下一篇

猜你喜欢

热点阅读