Skip to content

RAYDENFilipp/MongoDB

Repository files navigation

MongoDB

BSA Lection - 3: MongoDB

This lesson was completed with use of Studio 3T.

  1. A query to search for all students who's score > 87% and < 93% for any of the types of completed assignments(query result):
db.philippLypniakov.find({
    "scores": {
        $elemMatch: {
            "score": {
                $gt: 87,
                $lt: 93
            }
        }
    }
});
  1. Write an aggregation query to select all students who have a test result (type: "exam") of more than 90% (use unwind)(query result):
db.philippLypniakov.aggregate(
	// Pipeline
	[
		// Stage 1
		{
			$unwind: {
			    path : "$scores"
			}
		},

		// Stage 2
		{
			$match: {
			 "scores.type" : "exam",
			 "scores.score" : { $gt : 90 }
			}
		},

	]
);
  1. Modify Dusty Lemmond's documents(query result; acknowledgement result):
//Update Dusty Lemmond documents
db.philippLypniakov.updateMany(
   {name : "Dusti Lemmond"},
   {$set : { "accepted" : true } }
);

//Return Dusty's documents
db.philippLypniakov.find({
    "name": "Dusti Lemmond"
});

About

BSA Lection - 3: MongoDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published