Create a collection “student” and insert a document with the following fields:
"usn":,"name":,"fathername":,"mothername":,"hobbies[],"admissiontype":,"age":,"income":,"
skills":[],"place":,"location":{"type":"Point","coordinates":[, ]},"college":,"comments":})
Insert at least 4 more documents using insertMany() function to the “student” collection
with above mentioned fields:
Display all the documents in the collection:
Display the document of “usn”:1 in the collection:
Display only the first two documents in the collection:
Display the 2nd and 3rd document in the collection:
Display the document of “usn”:1 in the collection and project only the “usn” and
“name” of the document:
Update the document of “usn”:1 by setting a new array field “mark”: to the document:
Display the document of “usn”:1
From the document of “usn”:1 pop the last element from the array field “marks”:
Display the document of “usn”:1
To the document of “usn”:1 push’ 66’ to the array field “marks”:
Update the document of “usn”:2 by setting a new array field “mark”: to the document:
Display the document of “usn”:2
Display all the documents where the “marks” field is greater than ‘99’
Display all the documents where the “marks” field is greater than ‘99’ and less than ‘70’
Update all the documents by pushing two more array elements: ["baking","surfing"] to
the “hobbies”: array field
Display all the documents in the collection:
Update the document of “usn”:1 by pushing two more array elements ["it","testing"] to
the “skills”: array field by SORTING it in ascending order
Create an 2dshpere index for the “location”: field
Write a geospatial query to find the nearby location with maximum distance of 10000
meters (for the “location”: field)
Create a Text Index for the “comments”: field and search using some “keyword”
Text search using some “keyword” AND exclude some “keyword” for the “comments”:
Write aggregate query to find the average income by grouping based on “age”: field
Write aggregate query to find the average income by grouping based on
“admissiontype”: field
Write a pipeline aggregate query to find the documents with “age”: greater than 25,
sort it based on “age”: skip the first document and project only the
fields,”usn”:,”name”:,”age”: