- aggiornamento cataloghi.

possibilità di estrapolare i dati da GM direttamente
- migrazione delle tabelle di GM in locale
- corretto l'ordinamento del Catalogo
This commit is contained in:
Surya Paolo
2025-04-18 13:23:59 +02:00
parent fba2ebd710
commit ad45ce60ee
13 changed files with 988 additions and 106 deletions

View File

@@ -0,0 +1,58 @@
const mongoose = require('mongoose');
const { Schema } = mongoose;
mongoose.Promise = global.Promise;
mongoose.level = "F";
/**
* @typedef {Object} StatoProdotto
* @property {bigint} Id
* @property {number} IdStatoProdotto
* @property {string} Descrizione
* @property {Date} DataOra
* @property {boolean} Enabled
* @property {boolean} EnabledAlFresco
*/
const StatoProdottoSchema = new Schema({
IdStatoProdotto: Number,
Descrizione: { type: String, maxlength: 100 },
DataOra: Date,
Enabled: Boolean,
EnabledAlFresco: Boolean
}, { collection: 't_web_statiprodottos' });
const T_WEB_StatiProdotto = module.exports = mongoose.model('T_WEB_StatiProdotto', StatoProdottoSchema);
module.exports.findAllIdApp = async function () {
const myfind = {};
const myquery = [
{
$group: {
_id: "$IdStatoProdotto",
record: { $max: "$DataOra" }
}
},
{
$lookup: {
from: 't_web_statiprodottos',
localField: '_id',
foreignField: 'IdStatoProdotto',
as: 'record'
}
},
{
$replaceRoot: { newRoot: { $arrayElemAt: ["$record", 0] } }
},
{
$sort: { IdStatoProdotto: 1 }
}
];
return await T_WEB_StatiProdotto.aggregate(myquery);
};