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()
>
>
'database' 카테고리의 다른 글
mysql -- data type ; INT(4) vs. INT 차이 (0) | 2016.01.19 |
---|---|
mssql -- round ; 소수점 자리수 반올림 또는 제거 (0) | 2015.12.09 |
MongoDB -- 외부접속 허용 (0) | 2015.11.08 |
mysql -- 사용자 추가, 권한 부여 (0) | 2015.11.07 |
mysql -- 원격접속 허용 설정 및 사용자 등록 (0) | 2015.11.07 |