- 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:
58
src/server/models/t_web_statiprodotto.js
Executable file
58
src/server/models/t_web_statiprodotto.js
Executable 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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user