Group Page : visibility, some info, members views.

This commit is contained in:
paoloar77
2022-08-10 17:07:02 +02:00
parent 680b353535
commit 07f42398da
7 changed files with 93 additions and 18 deletions

View File

@@ -368,6 +368,54 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req)
};
};
MyGroupSchema.statics.extractCitiesName = async function(idapp, id) {
try {
let aggr1 = [
{
$match: {idapp, _id: id},
},
{
$lookup: {
from: 'cities',
localField: 'idCity',
foreignField: '_id',
as: 'mycities',
},
},
{
'$replaceRoot': {
'newRoot': {
'$mergeObjects': [
{
'$arrayElemAt': [
'$mycities',
0,
],
},
'$$ROOT',
],
},
},
},
{
$project: {
"mycities.comune": 1,
"mycities.prov": 1
},
},
];
ris = await this.aggregate(aggr1);
return ris;
}catch (e) {
console.error('e', e);
}
};
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
module.exports = {MyGroup};