-
Notifications
You must be signed in to change notification settings - Fork 0
/
Asgn_9.js
78 lines (61 loc) · 1.24 KB
/
Asgn_9.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//INSERTION
db.Student.insertOne({
rollno: 31253,
name: "Ninad",
marks: 93,
address: [
{
city: "Pune",
pin: 411046,
}
]
});
// SEARCHING
db.Student.find();
db.Student.find({name:"Ninad"});
db.Student.find({name:"Ninad", marks: {$gt: 90}});
db.Student.find({name:"Ninad"}).limit(1);
db.Student.find({name:"Ninad"}).sort({marks: 1});
db.Student.find({name:"Ninad"}).skip(1);
db.Student.find({name:"Ninad"}).count();
db.Student.find({marks: {$in: [80,90]}}); //$in , $nin
//$gt, $lt, $gte, $lte, $ne
db.Student.find({
//$not,$and
$or: [
{name: "Ninad"},
{marks: {$gt: 80}}
]
});
db.Student.find(
{"address.city": "Pune"}
);
//DELETION
db.Student.deleteOne({name: "Ninad"});
//UPDATION
db.Student.updateOne(
{name: "Ninad"},
{$set: {"address.city": "mumbai"}}
);
db.Student.updateOne(
{name: "Ninad"},
{$set: {marks: 95}}
);
db.Student.insertOne({
name: "Vinit",
rollno: 31254,
branch: "CE",
marks: [90,87,91,98],
});
db.Student.find(
{name: "Vinit"},
{"marks": {$slice: 2}},
);
db.Student.find({
name: "Vinit",
marks: {$size: 4},
});
db.Student.updateOne(
{name: "Vinit"},
{$push: {marks: 78}}
);