-
Notifications
You must be signed in to change notification settings - Fork 0
/
query-answers.txt
120 lines (96 loc) · 2.82 KB
/
query-answers.txt
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
------------------------------------------Find all the topics and tasks which are thought in the month of October------------------------------------------------------
Query =>>>> db.topics.aggregate([
{$lookup:{
from: "tasks",
localField:"topic_id",
foreignField: "topic_id",
as: "task"
}
},
{$match:{
$and:[
{start_date:{$gte:ISODate('2023-10-01'),$lte:ISODate('2023-10-31')}},
{"task.deadline_date":{$gte:ISODate('2023-10-01'),$lte:ISODate('2023-10-31')}}
]
}
},
{$project:{
task_id:0
}
},
{$project:{
"task":{"topic_id":0}
}
}
]);
-----------------------------------------Find all the company drives which appeared between 15 oct-2023 and 31-oct-2023-----------------------------------------------
Query=>>>>
db.companydrives.aggregate([{$match:
{drive_date:{$gte:ISODate('2023-10-15'),$lte:ISODate('2023-10-31')}}
}]);
-------------------------------------------Find all the company drives and students who are appeared for the placement.------------------------------------------------
Query=>>>> db.companydrives.aggregate([
{$lookup:{
from: "users",
localField:"userid",
foreignField: "userid",
as: "student"
}
},{$project:{
userid:0
}
},{$project:{
student:{_id:0}
}
}
]);
--------------------------------------------Find the number of problems solved by the user in codekata---------------------------------------------------------------
Query=>>>> db.users.aggregate([
{$lookup:{
from: "codekata",
localField: "userid",
foreignField: "user_id",
as: "codekata"
}
},{$project:{
"codekata":{_id:0,user_id:0}
}
}
]);
---------------------------------------------Find all the mentors with who has the mentee's count more than 15--------------------------------------------------------
Query>>>> db.mentors.aggregate([
{$match:{
mentees:{$gt:15}
}},{$project:{
_id:0
}}
]);
------------------------------Find the number of users who are absent and task is not submitted between 15 oct-2023 and 31-oct-2023----------------------------------
Query=>>> db.users.aggregate([
{
$lookup:{
from: "attendance",
localField: "userid",
foreignField: "userid",
as: "attendance",
}
},{
$lookup:{
from: "task_completion",
localField: "userid",
foreignField: "userid",
as: "task-comp",
}
},{
$match:{
$and: [
{
"attendance.attendance": false,"attendance.Class_date":{$gte:ISODate('2023-10-15'),$lte:ISODate('2023-10-31')}
},
{
"task-comp.task_completion": false,
},
],
}
}
]);