`

mongodb-win32-x86_64-2008plus-ssl-3.2.0-signed Hello World

 
阅读更多

 

Windows PowerShell
版权所有 (C) 2009 Microsoft Corporation。保留所有权利。

PS C:\Users\Administrator> mongo
2016-05-23T07:27:25.301+0800 I CONTROL  [main] Hotfix KB2731284 or later update is not installed, will zero-out data fil
es
MongoDB shell version: 3.2.0
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
> use mydatabase
switched to db mydatabase
> db.persons.insert({name:"xiongjiajia"})
WriteResult({ "nInserted" : 1 })
> show dbs
local       0.000GB
mydatabase  0.000GB
> show collections
persons
> db.system.indexes.find()
> db.persons.find()
{ "_id" : ObjectId("57424110232724e077252bd8"), "name" : "xiongjiajia" }
> db.persons.update({name:"xiongjiajia"},{$set:{name:"admin"}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.persons.find()
{ "_id" : ObjectId("57424110232724e077252bd8"), "name" : "admin" }
>  var p=db.persons.findOne();
> p
{ "_id" : ObjectId("57424110232724e077252bd8"), "name" : "admin" }
> db.persons.update(p,{name:"root"})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> var p=db.persons.findOne();
> p
{ "_id" : ObjectId("57424110232724e077252bd8"), "name" : "root" }
> db.persons.update({name:"root"},{$set:{name:"admin",age:1}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> var p=db.persons.findOne();
> p
{
        "_id" : ObjectId("57424110232724e077252bd8"),
        "name" : "admin",
        "age" : 1
}
> db.persons.remove({age:2})
WriteResult({ "nRemoved" : 0 })
> db.persons.find()
{ "_id" : ObjectId("57424110232724e077252bd8"), "name" : "admin", "age" : 1 }
> db.persons.remove({age:1})
WriteResult({ "nRemoved" : 1 })
> db.persons.find()
>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics