title: mongoDB | Database —

  • https://www.mongodb.com/docs/

クライアント

クライアントは5系以上はmongoshを使用する。 4系はmongoを使用する。

The legacy mongo shell was deprecated in MongoDB 5.0 and removed in MongoDB 6.0. The new MongoDB Shell, mongosh, offers numerous advantages over the legacy shell.

ref. MongoDB Shell (mongosh)

Amazon Linux / Ubuntu

Query

Query Documents

のQuery。

# 4系
# 接続
$ mongosh -u root -p pass
# Query
> show dbs
> show collections
> db.users.insert({id:1, email:"info@example.com"});
  WriteResult({ "nInserted" : 1 })
> db.users.find();
  { "_id" : ObjectId("6455d8191fa445e35cb1b066"), "id" : 1, "email" : "info@example.com" }
> db.users.countDocuments({})
  1

ref. https://buzz-server.com/tech/mongodb-command-list/#toc5

Amazon linux 2へのインストール