NoSQLの一種
- データベースにcollection(RDBでいうtable)を作成し、中にdocumentというrecordを作成する
- documentは実質?JSON
- 今のところ違いがわからない
- documentは実質?JSON
show dbsでデータベースの一覧を確認できるuse <db name>でデータベースを選択し、db.<collection name>.<operation>()でcollectionを操作できる- collectionへの操作は Collection Methods - Database Manual - MongoDB Docs を見ると良い
find()などでは$eqや$regexといった演算子を使用することができる
test> use example switched to db example example> db.users.insertMany([ ... { name: "Alice", email: "[email protected]", age: 7 }, ... { name: "Bob", emali: "[email protected]", age: 24}, ... ]) { acknowledged: true, insertedIds: { '0': ObjectId('6876026292f8fdadc6baa8b9'), '1': ObjectId('6876026292f8fdadc6baa8ba') } } example> db.users.find() [ { _id: ObjectId('6876026292f8fdadc6baa8b9'), name: 'Alice', email: '[email protected]', age: 7 }, { _id: ObjectId('6876026292f8fdadc6baa8ba'), name: 'Bob', emali: '[email protected]', age: 24 } ] example> db.users.findOne({name: "Bob"}) { _id: ObjectId('6876026292f8fdadc6baa8ba'), name: 'Bob', emali: '[email protected]', age: 24 } example> db.users.find({age: {$lte: 12}}) [ { _id: ObjectId('6876026292f8fdadc6baa8b9'), name: 'Alice', email: '[email protected]', age: 7 } ]docker run -d --rm --name mongodb mongoしてdocker exec -it mongodb mongoshとすると対話環境を開けるよ