- Fare LISTA MOVIMENTI più comprensibile
- Grafica Circuiti
This commit is contained in:
@@ -15,6 +15,9 @@ const { Settings } = require('../models/settings');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
var ObjectId = mongoose.Types.ObjectId;
|
||||
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true;
|
||||
@@ -68,8 +71,8 @@ StatSchema.statics.updateStats = async function (datastat) {
|
||||
|
||||
datastat.last_transactions.forEach(function (mov) {
|
||||
let ris = tools.getStringaConto(mov)
|
||||
mov.myfrom = ris.myfrom
|
||||
mov.myto = ris.myto
|
||||
mov.userfrom = ris.userfrom
|
||||
mov.userto = ris.userto
|
||||
mov.tipocontofrom = ris.tipocontofrom
|
||||
mov.tipocontoto = ris.tipocontoto
|
||||
});
|
||||
@@ -113,11 +116,12 @@ StatSchema.statics.calculateStats = async function (idapp) {
|
||||
};
|
||||
|
||||
// Trova il record di oggi:
|
||||
const trova_se_oggi = await Stat.findOne({ idapp, date_created: { $gte: new Date(new Date().setHours(0, 0, 0, 0)) } });
|
||||
const trova_se_oggi = await Stat.findOne({ idapp, date_created: { $gte: new Date(new Date().setHours(0, 0, 0, 0)) } }).lean();
|
||||
|
||||
if (trova_se_oggi) {
|
||||
// Aggiorna il record di oggi:
|
||||
await Stat.updateOne({ _id: trova_se_oggi._id }, { $set: datastat });
|
||||
const ris = await Stat.findOneAndUpdate({ _id: trova_se_oggi._id }, { $set: datastat }, { new: true });
|
||||
console.log('ris', ris);
|
||||
} else {
|
||||
// Aggiungi un nuovo record:
|
||||
await Stat.insertMany([datastat]);
|
||||
|
||||
Reference in New Issue
Block a user