Edited at

mongo コマンド一覧

More than 1 year has passed since last update.


mongoコマンド一覧


db確認コマンド

> show dbs

admin 0.078GB

crowidb 0.078GB

local 0.078GB

searchdb 0.078GB

test 0.078GB

test_db 0.078GB


DB切り替え

> use crowidb


コレクション一覧確認

>show collections

attachments

bookmarks

comments

configs

pages

revisions

searchwords

system.indexes

updateposts

user

users

words


DB確認


db.pages.find()

{ "_id" : ObjectId("XXXXXXXXXXXXXXXXXXXXXXX")...........以下省略



DB詳細確認(2017年10月1日の日報のみ抽出)

> db.pages.find({path: "/user/yamada/日報/2017/10/01"})

> db.users.find( {name:'山田 太郎'} )

{ "id" : ObjectId("58fa23767ffd2fbb09ef557d"), "password" : "e740e6904141efbcc221e183d50267dcbed95920eb214dc2f94bf587bc44e87d", "email" : "yamada@test.jp", "username" : "yamada", "name" : "山田 太郎", "admin" : true, "createdAt" : ISODate("2017-04-21T15:21:26.581Z"), "status" : 2, "_v" : 0, "apiToken" : "CzkEzDxllZ9ZPbvJsw/W21XrhNLQd7pbpM5IxMB0eGY=" }

> db.users.find().forEach(function(user){print (user.username + "," + user.name);})

test,てすと

test1,てすといち

test2,てすとに

※function(user)←変数


DB削除

pages

> db.pages.remove({path: "/user/yamada/日報/2017/10/17"})

user

> db.users.remove( {name:'ぱち'} )

WriteResult({ "nRemoved" : 1 })