- Add saldo to member's list
This commit is contained in:
177
src/server/tools/prova.js
Normal file
177
src/server/tools/prova.js
Normal file
@@ -0,0 +1,177 @@
|
||||
[
|
||||
{
|
||||
"0": {
|
||||
"$match": {
|
||||
"idapp": "13",
|
||||
"profile.mycircuits": {
|
||||
"$elemMatch": {
|
||||
"circuitname": {
|
||||
"$eq": "RISO Test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"$lookup": {
|
||||
"from": "circuits",
|
||||
"as": "circuit",
|
||||
"let": {
|
||||
"circuitname": "RISO Test",
|
||||
"idapp": "$idapp"
|
||||
},
|
||||
"pipeline": [
|
||||
{
|
||||
"$match": {
|
||||
"$expr": {
|
||||
"$and": [
|
||||
{
|
||||
"$eq": [
|
||||
"$name",
|
||||
"$$circuitname"
|
||||
]
|
||||
},
|
||||
{
|
||||
"$eq": [
|
||||
"$idapp",
|
||||
"$$idapp"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"$unwind": "$circuit"
|
||||
},
|
||||
"3": {
|
||||
"$project": {
|
||||
"username": 1,
|
||||
"profile": 1,
|
||||
"idapp": 1,
|
||||
"circuit.name": 1,
|
||||
"circuit._id": 1
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"$lookup": {
|
||||
"from": "accounts",
|
||||
"as": "account",
|
||||
"let": {
|
||||
"username": "$username",
|
||||
"idapp": "$idapp",
|
||||
"circuitId": "$circuit._id"
|
||||
},
|
||||
"pipeline": [
|
||||
{
|
||||
"$match": {
|
||||
"$expr": {
|
||||
"$and": [
|
||||
{
|
||||
"$eq": [
|
||||
"$$username",
|
||||
"$username"
|
||||
]
|
||||
},
|
||||
{
|
||||
"$eq": [
|
||||
"$$idapp",
|
||||
"$idapp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"$eq": [
|
||||
"$$circuitId",
|
||||
"$circuitId"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"5": {
|
||||
"$unwind": "$account"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$match": {
|
||||
"idapp": "13"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$sort": {
|
||||
"desc": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"myId1": {
|
||||
"$toObjectId": "$userId"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "users",
|
||||
"localField": "myId1",
|
||||
"foreignField": "_id",
|
||||
"as": "user"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$user",
|
||||
0
|
||||
]
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"username": 1,
|
||||
"profile.img": 1,
|
||||
"profile.mycircuits": 1,
|
||||
"profile.qualifica": 1,
|
||||
"account.saldo": 1,
|
||||
"reported": 1,
|
||||
"date_report": 1,
|
||||
"username_who_report": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$group": {
|
||||
"_id": null,
|
||||
"count": {
|
||||
"$sum": 1
|
||||
},
|
||||
"results": {
|
||||
"$push": "$$ROOT"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"count": 1,
|
||||
"rows": {
|
||||
"$slice": [
|
||||
"$results",
|
||||
0,
|
||||
10
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user