We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 432f841 commit b508f24Copy full SHA for b508f24
Practice/Mongo/users.js
@@ -0,0 +1,19 @@
1
+use practice;
2
+
3
+db.users.insert({ name: 'Adam', username: 'adam', password: 'adam123' });
4
+db.users.updateOne({ username: 'adam' }, { $set: { roles: ['student', 'faculty'] } })
5
6
+db.users.insertOne({
7
+ name: 'ben',
8
+ username: 'ben',
9
+ password: 'ben123'
10
+})
11
+db.users.updateOne({ name: 'ben' }, { $set: { roles: ['faculty'] } });
12
13
+db.users.aggregate([{ $unwind: '$roles' }])
14
+db.users.aggregate([{ $unwind: '$roles' }, { $group: { _id: '$roles', total: { $count: {} } } }])
15
16
+db.users.find();
17
+db.users.count;
18
19
+db.users.drop();
0 commit comments