The two most important days in your life are the day you are born and the day you find out why.................................Mark Twain
Tuesday, October 18, 2022
Monday, October 17, 2022
CDN javascript libraries
Syntax Highlighter Libraries
https://cdnjs.com/libraries/SyntaxHighlighter
Google Prettify Libraries
https://cdnjs.com/libraries/prettify
Adding syntax highlighter in the blogger posts
To add syntax highlighting to the code in the post:
Add following script tag in the head tag of the html of the template
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
Refer the link below for more details:
https://github.com/googlearchive/code-prettify
Friday, October 14, 2022
mongodb update queries
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 } } )
mongodb find queries
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"})
Mongodb Insert Document Query
Insert Documents:
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
}
]
}
])
Subscribe to:
Posts (Atom)