Lista Navi

This commit is contained in:
Paolo Arena
2020-04-07 14:34:29 +02:00
parent 8c9a5f7518
commit 7c575c0687
14 changed files with 317 additions and 154 deletions

View File

@@ -77,6 +77,62 @@ const NavePersistenteSchema = new mongoose.Schema({
}
});
function getQueryProj(myfilter) {
myobjField = {
_id: 1,
idapp: 1,
lang: 1,
ind_order: 1,
name: 1,
surname: 1,
username: 1,
'profile.paymenttypes': 1,
'profile.email_paypal': 1,
'profile.cell': 1,
made_gift: 1,
sent_msg_howto_make_gift: 1,
date_made_gift: 1,
note: 1,
received_gift: 1,
date_received_gift: 1,
num_tess: 1,
indprimario: 1,
parent_id: 1,
riga: 1,
col: 1,
created: 1,
// date_start: 1,
// date_gift_chat_open: 1,
// link_chat: 1,
// provvisoria: 1,
// note_bot: 1,
// note_interne: 1,
// tutor: 1,
// tutor_namesurname: 1,
};
const query = [
{ $match: myfilter },
{
$lookup: {
from: "users",
localField: "ind_order",
foreignField: "ind_order", // field in the user collection
as: "user"
}
},
{
$replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$user", 0] }, "$$ROOT"] } }
// $replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$user", 0] },] } }
},
{ $project: myobjField }
];
return query;
}
NavePersistenteSchema.statics.findById = function (idapp, id) {
const NavePersistente = this;