「Ubuntu20.04」mongodbをshellで利用する方法

1.テーブルを作成

> db.version();
5.0.3
> db.createCollection("users")
{ "ok" : 1 }

2.データを挿入

> db.items.insert( { username:"user008", age:30,addr:"tokyo" } );
WriteResult({ "nInserted" : 1 })

> db.items.insert( { username:"user009", age:25,addr:"oosaka" } );
WriteResult({ "nInserted" : 1 })

3.挿入したデータを確認

> db.items.find();
{ "_id" : ObjectId("615cd16fce236fa9f5febacf"), "username" : "user008", "age" : 30, "addr" : "tokyo" }
{ "_id" : ObjectId("615cd195ce236fa9f5febad0"), "username" : "user009", "age" : 25, "addr" : "oosaka" }

4.shellを終了
> quit()

Ubuntu 20.04

Posted by arkgame