for Javascript Developers
SRI SAI SWAROOP KOMMINENI
Full Stack Javascript Developer
B. Tech and M. Tech from IIT Bombay
CHAPTER 1: INTRODUCTION
CHAPTER 2: CRUD
CHAPTER 3: SCHEMA DESIGN
CHAPTER 4: PERFORMANCE
CHAPTER 5: AGGREGATION FRAMEWORK
CHAPTER 6: APPLICATION ENGINEERING
CHAPTER 7: MONGOOSE
50 % Lab
50 % Theory
JSON is built on two structures:
{
"key": "value"
}
["element1", "element2", "element3"]
{}
{
"key": "value"
}
{
"string": "Hello World",
"boolean": true,
"boolean2": false,
"null": null,
"number": 123,
"number1": 123.25,
"number1": 12e2,
"array": [ 1, "2", 3.5, false, null ],
"object": {
"a": "b",
"c": null,
"e": false
}
}
[]
[ 1, 2, 3]
["string", false, null, { "name" : "sai" }]
[
"string",
false,
null,
{
"name" : "your name"
},
{
"month" : "August",
"day" : 15,
"birthday": false,
"SQL" : null
}
]
Objects
Arrays
Which of the following data types are directly supported by JSON per the JSON spec?
MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need
MongoDB eliminates a number of technical challenges that slow the pace of app development.
MongoDB stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time
The document model maps to the objects in your application code, making data easy to work with
Ad hoc queries, indexing, and real time aggregation provide powerful ways to access and analyze your data
MongoDB is a distributed database at its core, so high availability, horizontal scaling, and geographic distribution are built in and easy to use
MongoDB is free and open-source, published under the GNU Affero General Public License
Compass is a visual interface to MongoDB thats lets us connect to the database and explore the datasets.
MongoDB represents JSON documents in binary-encoded format called BSON behind the scenes. BSON extends the JSON model to provide additional data types, ordered fields, and to be efficient for encoding and decoding within different languages.
MongoDB queries are represented as a JSON-like structure, just like documents. To build a query, you specify a document with properties you wish the results to match.
Atomicity is an all-or-none proposition.
Consistency guarantees that a transaction never leaves your database in a half-finished state.
Isolation keeps transactions separated from each other until they’re finished.
Durability guarantees that the database will keep track of pending changes in such a way that the server can recover from an abnormal termination.
Which of the following statements are true? Check all that apply.
Documents are stored in collections.
A database may contain one or more collections.
Each database and collection combination define a namespace.
We reference a namespace using the name of the database, followed by a comma, followed by the name of the collection, e.g., city,neighborhoods.
We won't talk about indexes too much in this chapter
Which of the following are types of data Compass (and MongoDB) recognizes and specifically supports?
Which of statements below best describes the following filter?
{"age": {"$gte": 21, "$lt": 70}}
When connecting to an Atlas cluster using the shell, why do we provide the hostnames for all nodes when we launch mongo? Choose the best answer from the choices below.
insertOne()
insertMany()
Other way to insert is using an update operation which is called Upsert
Which of the following statements are true of creating documents in MongoDB?
find()
Projections
updateOne()
Update Operators
Which of the following best describes the purpose of update operators? choose best answer.
updateMany()
uspert
third parameter for the updateOne function
var detail = {} // the actual movie object
db.movieDetails.updateOne({
"imdb.id”: detail.imdb.id
}, {
$set: detail
}, {
upsert: true
})
replaceOne()
var detailDoc = {} // the actual movie object
db.movieDetails.replaceOne({
"imdb.id”: detailDoc.imdb.id
},
detailDoc
)
Suppose you wish to update the value of the plot field for one document in our movieDetailscollection to correct a typo. Which of the following update operators and modifiers would you need to use to do this?
deleteOne()
deleteMany()