Syntax Highlighter Libraries
https://cdnjs.com/libraries/SyntaxHighlighter
Google Prettify Libraries
https://cdnjs.com/libraries/prettify
The two most important days in your life are the day you are born and the day you find out why.................................Mark Twain
Syntax Highlighter Libraries
https://cdnjs.com/libraries/SyntaxHighlighter
Google Prettify Libraries
https://cdnjs.com/libraries/prettify
db.post.update({ _id: ObjectId("634940d222dc636741bd70d4") }, {
$set: {
"title": "MongoDB Overview",
"description": "MongoDB is no SQL database",
"by": "tutorials point",
"url": "http://www.tutorialspoint.com",
"tags": ["mongodb", "database", "NoSQL"],
"likes": 99
}
})
{
_id: 4,
grades: [
{ grade: 80, mean: 75, std: 8 },
{ grade: 85, mean: 90, std: 5 },
{ grade: 85, mean: 85, std: 8 }
]
}
Update Documents in an Array
db.students.updateOne(
{ _id: 4, "grades.grade": 85 },
{ $set: { "grades.$.std" : 6 } }
)
Update Embedded Documents Using Multiple Field Matches
db.students.updateOne(
{
_id: 5,
grades: { $elemMatch: { grade: { $lte: 90 }, mean: { $gt: 80 } } }
},
{ $set: { "grades.$.std" : 6 } }
)
Update with Multiple Array Matches
db.students_deans_list.updateOne(
{ activity_ids: 1, grades: 95, deans_list: 2021 },
{ $set: { "deans_list.$": 2022 } }
)
db.post.find()
//find for string in an array of strings
db.post.find({"tags":"NoSQL"})
//find for string in the nested document. Find where user = "user1" inside comments document
db.post.find({"comments.user":"user1"})
db.post.insert(
[
{
title: "MongoDB Overview",
description: "MongoDB is no SQL database",
by: "tutorials point",
url: "http://www.tutorialspoint.com",
tags: ["mongodb", "database", "NoSQL"],
likes: 100
},
{
title: "NoSQL Database",
description: "NoSQL database doesn't have tables",
by: "tutorials point",
url: "http://www.tutorialspoint.com",
tags: ["mongodb", "database", "NoSQL"],
likes: 20,
comments:
[
{
user:"user1",
message: "My first comment",
dateCreated: new Date(2013,11,10,2,35),
like: 0
}
]
}
])