-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprac6.js
61 lines (39 loc) · 1.34 KB
/
prac6.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
db.Customers.aggregate( { $match : {AccType : "S" } },
{ $group : { _id : "$CustID",TotAccBal : { $sum : "$AccBal" } } });
db.Customers.aggregate( { $match : {AccType : "S" } },
{ $group : { _id : "$CustID",TotAccBal : { $sum : "$AccBal" } } },
{ $match : {TotAccBal : { $gt : 1200 } }});
db.Customers.find();
db.Customers.insert([
{ CustID: "C123",
AccBal: 500,
AccType: "S"},
{ CustID: "C123",
AccBal: 900,
AccType: "S"},
{ CustID: "C111",
AccBal: 1200,
AccType: "S"},
{ CustID: "C123",
AccBal: 1500,
AccType: "C"}]);
db.Customers.mapReduce(
function(){ emit(this.CustID, this.AccBal);},
function(key, values){ return Array.sum( values )},
{
query : {AccType: "S"},
out: "amunt_total"
}
)
db.amunt_total.find();
db.Students.count();
db.Students.find();
db.post.find()
db.post.find({ Description: { $regex: 'tables' } });
db.post.find({ Tages: { $regex: 'database',$options: "$i" } });
db.post.find({ Tages: { $regex: 'database' } });
db.Students.find().sort({StudName:-1,Location:-1})
db.Students.find();
db.Students.find().skip(2)
db.Students.find().skip(2).limit(2)
db.Students.find().skip(db.Students.count()-2)