Send Coins
This commit is contained in:
@@ -118,11 +118,14 @@ MovementSchema.statics.addMov = async function(idapp, accountFromId, accountToId
|
||||
|
||||
MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username, circuitId) {
|
||||
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false);
|
||||
try {
|
||||
if (!circuitId) {
|
||||
return [];
|
||||
}
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, {circuitId}, false);
|
||||
|
||||
if (myaccount) {
|
||||
if (myaccount) {
|
||||
|
||||
try {
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: {
|
||||
@@ -173,6 +176,28 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
},
|
||||
},
|
||||
{$unwind: '$accto'},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "circuits",
|
||||
"localField": "accfrom.circuitId",
|
||||
"foreignField": "_id",
|
||||
"as": "circuitfrom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$unwind": "$circuitfrom"
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "circuits",
|
||||
"localField": "accto.circuitId",
|
||||
"foreignField": "_id",
|
||||
"as": "circuitto"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$unwind": "$circuitto"
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
@@ -202,6 +227,8 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
@@ -212,10 +239,10 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
];
|
||||
|
||||
return aggr1;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
@@ -226,7 +253,7 @@ MovementSchema.statics.getMovsByCircuitId = async function(idapp, username, circ
|
||||
|
||||
const myquery = await MyMovement.getQueryMovsByCircuitId(idapp, username, circuitId);
|
||||
|
||||
if (myquery) {
|
||||
if (myquery && myquery.length > 0) {
|
||||
ris = await MyMovement.aggregate(myquery);
|
||||
|
||||
return ris;
|
||||
|
||||
Reference in New Issue
Block a user