Câu 7: C100DEV: MongoDB Associate Developer
A products collection needs to update the value of the qty field to 100 for a document with a “card” item value. It should insert a new document if it does not exist. What command should be used?
Nội dung câu hỏi
A products collection needs to update the value of the qty field to 100 for a document with a “card” item value. It should insert a new document if it does not exist. What command should be used?
Các lựa chọn
Đáp án được giữ gọn theo nhãn A, B, C, D trong phần bình chọn tương tác.
- A. db.products.updateOne({ item: “card”} , { $set: { qty: 100 } }, { $upsert: true })
- B. db.products.insertOne( { item: “card”} , { $set: { qty: 100 } }, { $upsert: true })
- C. db.products.insertOne( { item: “card”} , { $set: { qty: 100 } }, { upsert: true })
- D. db.products.updateOne({ item: “card”} , { $set: { qty: 100 } }, { upsert: true }) — đáp án hiện tại
Cộng đồng
0 bình luận công khai. Tên thành viên được ẩn một phần.
Chưa có bình luận. Mở giao diện tương tác để bắt đầu thảo luận.