shell語法可支援直接在終端機上查詢mongoDB
新增單筆資料
collection名稱為定義的table名 ⇒ ex: db.rooms.insertOne({"rating": 4.5,"price": 2800, "name": "標準單人房"})
db.collection.insertOne(<data>,<options>)
db.collection.insertMany(<data>,<options>)
更新單筆資料
filter為要篩選的資料
db.collection.updateOne(<filter>,<data>,<options>)
db.rooms.updateOne({"_id": ObjectId('6419348f8047372165b05e72')}, {"$set": {"price": 2500}})
db.collection.updateMany(<filter>,<data>,<options>)
db.rooms.updateMany({"rating": 4.5},{"$set": {"rating": 0}})
更新整筆資料
和update類似,update只會更改資料中對應的欄位,replaceOne是更新給定的資料
db.collection.replaceOne(<filter>,<data>,<options>)
db.rooms.replaceOne({"rating": 0},{"price": 0})