標籤:com 查詢 tle mat ref 1.2 分享 drop 刪除資料庫
MongoDB配置 本地啟動
c:\MongoDB\bin>mongod.exe --dbpath "C:\\MongoDB\data\db" --logpath "c:\\MongoDB\
Data\log\Mongodb.log"
C:\Users\jiangchunming>cd C:\MongoDB\bin
C:\MongoDB\bin>mongo.exe --port 27017
Mongodb插入時間
> db.orders.insert({id:104,title:"yuiyuig",price:18.9,addtime:new Date(2017,0,31
,12,01,00)})
刪除資料庫
查詢資料庫
MongoDB修改資料
{ "_id" : ObjectId("5901a40981f45b10993c9d58"), "id" : 1101, "name" : "person",
"age" : 222, "address" : "china" }
> db.user.insert({id:1101,name:test})
2017-04-27T16:22:31.997+0800 E QUERY [thread1] ReferenceError: test is not de
fined :
@(shell):1:25
> db.user.insert({id:1101,name:"test"})
WriteResult({ "nInserted" : 1 })
> db.user.find()
{ "_id" : ObjectId("5901aa5081f45b10993c9d59"), "id" : 1101, "name" : "test" }
> db.user.insert({id:1102,name:"dest"})
WriteResult({ "nInserted" : 1 })
> db.user.find()
{ "_id" : ObjectId("5901aa5081f45b10993c9d59"), "id" : 1101, "name" : "test" }
{ "_id" : ObjectId("5901aa6681f45b10993c9d5a"), "id" : 1102, "name" : "dest" }
*******************************************mongoDB修改資料操作*********************************************
修改Id
> var model = db.user.findOne({"name":"test"})
> model.id=1103
1103
> db.user.update({"name":"test"},model)
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.user.find()
{ "_id" : ObjectId("5901aa5081f45b10993c9d59"), "id" : 1103, "name" : "test" }
{ "_id" : ObjectId("5901aa6681f45b10993c9d5a"), "id" : 1102, "name" : "dest" }
>
*******************************************mongoDB修改資料操作*********************************************
https://git.oschina.net/lookingdreamer/RexDeploy_v1
*******************************************************************************************************************
MongoDB插入時間筆記
>db.orders.insert({id:104,title:"yuiyuig",price:18.9,addtime:new Date(2017,0,31
,12,01,00)})
插入目前時間:
> db.orders.insert({id:104,title:"yuiyuig",price:18,addtime:new Date()})
WriteResult({ "nInserted" : 1 })
http://xiaorui.cc/2014/05/01/mongodb%E7%9A%84%E6%97%A5%E6%9C%9F%E6%97%B6%E9%97%B4%E7%9A%84%E6%8F%92%E5%85%A5%E5%8F%8A%E6%9F%A5%E8%AF%A2/
插入目前時間:
> db.orders.insert({id:104,title:"yuiyuig",price:18,addtime:new Date().toLocaleS
tring()})
刪除資料庫
show dbs --展示資料庫
db.dropDatabase() --刪除資料庫
D:\MongoCTest\RiderPosition
D:\Projects\OTS\ExFresh.OTS\1. Presentation\1.2 API\Contract\O2OManager
MongoDB入門二