mongodb_lab_2
mongodb_lab_2
db.NOTES.countDocuments();
db.NOTES.insertMany([
{ "student_id": 200, "type": "exam", "score": 39.15737165675101 },
{ "student_id": 200, "type": "quiz", "score": 64.28777986675444 },
{ "student_id": 200, "type": "homework", "score": 17.15638165456321 },
{ "student_id": 200, "type": "homework", "score": 85.23345595675101 }
]);
db.NOTES.updateOne(
{ "student_id": 200, "type": "exam" },
{ $set: { "score": 59 } }
);
8. Set the same score (44) for all tests of student 200
Command:
db.NOTES.updateMany(
{ "student_id": 200 },
{ $set: { "score": 44 } }
);
db.NOTES.updateMany(
{ "student_id": 200 },
{ $inc: { "student_id": 2 } }
);
db.IMAGES.insertOne({
"_id": 100000,
"height": 480,
"width": 640,
"tags": ["cats", "dogs", "kittens"]
});
db.IMAGES.updateOne(
{ "_id": 9 },
{ $push: { "tags": "vacation" } }
);
db.IMAGES.updateOne(
{ "_id": 7 },
{ $set: { "tags.0": "cats" } }
);
db.IMAGES.updateOne(
{ "_id": 99977 },
{ $pull: { "tags": "work" } }
);