반응형

MongoDB -- 기초 사용법 


환경 : MongoDB 3.0.7,  Ubuntu 14.04 LTS 64bit Server


참고 : https://docs.mongodb.org/manual/reference/mongo-shell/

       http://www.tutorialspoint.com/mongodb/mongodb_create_database.htm

       https://docs.mongodb.org/manual/reference/method/db.collection.remove/#db-collection-remove




$ mongo

MongoDB shell version: 3.0.7

connecting to: test

Server has startup warnings: 

....


> show databases;

local  0.078GB

test   0.078GB

> show collections

kittens

system.indexes

tasks

test

>

> db.test.find()

{ "_id" : ObjectId("5633c97fa5573b594e08e196"), "a" : 1 }

> db.tasks.find()

{ "_id" : ObjectId("56473a412a4beb6503a325ed"), "contents" : "hap", "createDate" : ISODate("2015-11-14T13:42:25.461Z"), "status" : "TO-DO", "__v" : 0 }

{ "_id" : ObjectId("56473a542a4beb6503a325ee"), "contents" : "한글.", "createDate" : ISODate("2015-11-14T13:42:44.558Z"), "status" : "DONE", "__v" : 0 }

{ "_id" : ObjectId("56473a6d2a4beb6503a325ef"), "contents" : "하나", "createDate" : ISODate("2015-11-14T13:43:09.173Z"), "status" : "TO-DO", "__v" : 0 }

{ "_id" : ObjectId("56473a742a4beb6503a325f0"), "contents" : "하하", "createDate" : ISODate("2015-11-14T13:43:16.881Z"), "status" : "TO-DO", "__v" : 0 }

> db.tasks.remove({"status":"DONE"})

WriteResult({ "nRemoved" : 1 })

> db.tasks.find()

{ "_id" : ObjectId("56473a412a4beb6503a325ed"), "contents" : "hap", "createDate" : ISODate("2015-11-14T13:42:25.461Z"), "status" : "TO-DO", "__v" : 0 }

{ "_id" : ObjectId("56473a6d2a4beb6503a325ef"), "contents" : "하나", "createDate" : ISODate("2015-11-14T13:43:09.173Z"), "status" : "TO-DO", "__v" : 0 }

{ "_id" : ObjectId("56473a742a4beb6503a325f0"), "contents" : "하하", "createDate" : ISODate("2015-11-14T13:43:16.881Z"), "status" : "TO-DO", "__v" : 0 }

> db.tasks.remove({})

WriteResult({ "nRemoved" : 3 })

> db.tasks.find()




반응형
Posted by 자유프로그램
,