- Aggiornato node.js alla versione 22.18.1
- Aggiornato tutti i pacchetti del server all'ultima versione. - passato mongoose da versione 5 a versione 6
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "../.."
|
||||
},
|
||||
{
|
||||
"path": "../../../newfreeplanet"
|
||||
},
|
||||
{
|
||||
"path": "../../../cnm"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"search.useIgnoreFiles": false,
|
||||
"search.useParentIgnoreFiles": false,
|
||||
"files.exclude": {
|
||||
"": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +1,26 @@
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
mongoose.level = "";
|
||||
|
||||
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
mongoose.set('debug', false);
|
||||
mongoose.set('strictQuery', false);
|
||||
|
||||
let options = {
|
||||
// user: process.env.UDB,
|
||||
// pass: process.env.PDB,
|
||||
// useMongoClient: true,
|
||||
// useMongoClient: false,
|
||||
useNewUrlParser: true,
|
||||
// useFindAndModify: true,
|
||||
useFindAndModify: false,
|
||||
// useCreateIndex: true,
|
||||
useUnifiedTopology: true,
|
||||
|
||||
promiseLibrary: require('bluebird'),
|
||||
|
||||
// autoIndex: false, // Don't build indexes
|
||||
// reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
|
||||
// reconnectInterval: 500, // Reconnect every 500ms
|
||||
// poolSize: 10, // Maintain up to 10 socket connections
|
||||
// // If not connected, return errors immediately rather than waiting for reconnect
|
||||
// bufferMaxEntries: 0,
|
||||
// connectTimeoutMS: 10000, // Give up initial connection after 10 seconds
|
||||
// socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
|
||||
// family: 4 // Use IPv4, skip trying IPv6
|
||||
|
||||
// keepAlive: true, // keepAlive is true by default since mongoose 5.2.0
|
||||
// keepAliveInitialDelay: 300000 // keepAliveInitialDelay is the number of milliseconds to wait before initiating keepAlive on the socket.
|
||||
// useNewUrlParser: true,
|
||||
// useUnifiedTopology: true,
|
||||
maxPoolSize: 5,
|
||||
serverSelectionTimeoutMS: 30000,
|
||||
};
|
||||
|
||||
console.log('process.env.AUTH_MONGODB', process.env.AUTH_MONGODB);
|
||||
|
||||
if (process.env.AUTH_MONGODB === '1') {
|
||||
options.auth = {
|
||||
/*options.auth = {
|
||||
authSource: "admin",
|
||||
poolSize: 10,
|
||||
user: process.env.MONGODB_USER,
|
||||
username: process.env.MONGODB_USER,
|
||||
password: process.env.MONGODB_PWD,
|
||||
};
|
||||
};*/
|
||||
}
|
||||
|
||||
if (options.auth && options.auth.user) {
|
||||
@@ -61,8 +35,11 @@ console.log('Node Version ' + process.version);
|
||||
console.log('Mongoose Version ' + mongoose.version);
|
||||
|
||||
connectionUrl = process.env.MONGODB_URI;
|
||||
if (process.env.AUTH_MONGODB === '1') {
|
||||
connectionUrl = `mongodb://${process.env.MONGODB_USER}:${process.env.MONGODB_PWD}@localhost:27017/test_FreePlanet`;
|
||||
}
|
||||
|
||||
console.log('Connessione a ' + connectionUrl + ' in corso...');
|
||||
console.log('Connessione a ' + connectionUrl + ' in corso...', options);
|
||||
mongoose.connect(connectionUrl, options);
|
||||
|
||||
db.on('error', console.error.bind(console, 'connection error:'));
|
||||
|
||||
@@ -98,9 +98,7 @@ AccountSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp, deleted: false };
|
||||
|
||||
return await Account.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
return await Account.find(myfind).lean();
|
||||
};
|
||||
|
||||
AccountSchema.pre('save', async function (next) {
|
||||
@@ -764,8 +762,8 @@ AccountSchema.statics.updateSaldoAndTransato_AllAccounts = async function (idapp
|
||||
|
||||
const Account = mongoose.model('Account', AccountSchema);
|
||||
|
||||
Account.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Account.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
module.exports = { Account };
|
||||
|
||||
@@ -64,8 +64,9 @@ AdTypeSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
|
||||
const AdType = mongoose.model('AdType', AdTypeSchema);
|
||||
|
||||
AdType.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
AdType.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = {AdType};
|
||||
|
||||
@@ -64,8 +64,9 @@ AdTypeGoodSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
|
||||
const AdTypeGood = mongoose.model('AdTypeGood', AdTypeGoodSchema);
|
||||
|
||||
AdTypeGood.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
AdTypeGood.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = {AdTypeGood};
|
||||
|
||||
@@ -390,8 +390,9 @@ AttivitaSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
|
||||
const Attivita = mongoose.model('Attivita', AttivitaSchema);
|
||||
|
||||
Attivita.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Attivita.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Attivita };
|
||||
|
||||
@@ -49,6 +49,7 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
return await Author.find(myfind).sort({name: 1, surname: 1});
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -68,10 +68,7 @@ bookingSchema.statics.findAllByUserIdAndIdApp = function (userId, idapp, sall) {
|
||||
else
|
||||
myfind = { userId, idapp, booked: true };
|
||||
|
||||
return Booking.find(myfind, (err, arrbooked) => {
|
||||
// console.log('ris Booking:', arrbooked);
|
||||
return arrbooked
|
||||
});
|
||||
return Booking.find(myfind).lean();
|
||||
};
|
||||
|
||||
|
||||
@@ -94,7 +91,7 @@ function getUsersByBooking(idapp) {
|
||||
$Lookup: {
|
||||
from: "users",
|
||||
localField: "userId", // field in my collection
|
||||
foreignField: "ObjectId(_id)", // field in the 'from' collection
|
||||
foreignField: "new ObjectId(_id)", // field in the 'from' collection
|
||||
as: "fromItems"
|
||||
}
|
||||
},
|
||||
@@ -122,8 +119,9 @@ bookingSchema.statics.findAllDistinctByBooking = function (idapp) {
|
||||
|
||||
const Booking = mongoose.model('Booking', bookingSchema);
|
||||
|
||||
Booking.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Booking.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Booking };
|
||||
|
||||
@@ -205,8 +205,9 @@ BotSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const MyBot = mongoose.model('Bot', BotSchema);
|
||||
|
||||
MyBot.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MyBot.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MyBot };
|
||||
|
||||
@@ -76,8 +76,9 @@ CalZoomSchema.statics.getNextZoom = async function (idapp) {
|
||||
|
||||
const CalZoom = mongoose.model('CalZoom', CalZoomSchema);
|
||||
|
||||
CalZoom.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
CalZoom.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { CalZoom };
|
||||
|
||||
@@ -55,7 +55,7 @@ module.exports.getCartByUserId = async function (uid, idapp) {
|
||||
|
||||
if (!!mycart) {
|
||||
for (const idkey in mycart.items) {
|
||||
try {
|
||||
try {
|
||||
let idorder = mycart.items[idkey]._id.toString();
|
||||
let myorder = mycart.items[idkey].order;
|
||||
if (!!myorder) {
|
||||
@@ -89,32 +89,35 @@ module.exports.getCartByUserId = async function (uid, idapp) {
|
||||
|
||||
};
|
||||
|
||||
module.exports.updateCartByUserId = function (userId, newCart, callback) {
|
||||
module.exports.updateCartByUserId = async function (userId, newCart, callback) {
|
||||
let query = { userId: userId };
|
||||
Cart.find(query, function (err, c) {
|
||||
try {
|
||||
const c = await Cart.find(query);
|
||||
} catch (err) {
|
||||
if (err) throw err;
|
||||
}
|
||||
|
||||
//exist cart in databse
|
||||
if (c.length > 0) {
|
||||
Cart.findOneAndUpdate(
|
||||
{ userId: userId },
|
||||
{
|
||||
$set: {
|
||||
items: newCart.items,
|
||||
totalQty: newCart.totalQty,
|
||||
totalPrice: newCart.totalPrice,
|
||||
totalPriceCalc: newCart.totalPriceCalc,
|
||||
userId: userId,
|
||||
},
|
||||
//exist cart in databse
|
||||
if (c.length > 0) {
|
||||
Cart.findOneAndUpdate(
|
||||
{ userId: userId },
|
||||
{
|
||||
$set: {
|
||||
items: newCart.items,
|
||||
totalQty: newCart.totalQty,
|
||||
totalPrice: newCart.totalPrice,
|
||||
totalPriceCalc: newCart.totalPriceCalc,
|
||||
userId: userId,
|
||||
},
|
||||
{ new: true },
|
||||
callback,
|
||||
);
|
||||
} else {
|
||||
//no cart in database
|
||||
newCart.save(callback);
|
||||
}
|
||||
});
|
||||
},
|
||||
{ new: true },
|
||||
callback,
|
||||
);
|
||||
} else {
|
||||
//no cart in database
|
||||
newCart.save(callback);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports.updateCartByCartId = async function (cartId, newCart) {
|
||||
@@ -148,7 +151,7 @@ module.exports.updateCartByCartId = async function (cartId, newCart) {
|
||||
};
|
||||
|
||||
module.exports.deleteCartByCartId = async function (cartId) {
|
||||
return await Cart.remove({ _id: cartId });
|
||||
return await Cart.deleteOne({ _id: cartId });
|
||||
};
|
||||
|
||||
module.exports.createCart = async function (newCart) {
|
||||
@@ -156,6 +159,7 @@ module.exports.createCart = async function (newCart) {
|
||||
};
|
||||
|
||||
|
||||
Cart.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Cart.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -28,9 +28,10 @@ const CashCategorySchema = new Schema({
|
||||
|
||||
var CashCategory = module.exports = mongoose.model('CashCategory', CashCategorySchema);
|
||||
|
||||
CashCategory.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
CashCategory.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return []
|
||||
|
||||
@@ -70,6 +70,7 @@ module.exports.createCashSubCategory = async function (CashSubCategory) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -54,8 +54,9 @@ CatAISchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const CatAI = mongoose.model('CatAI', CatAISchema);
|
||||
|
||||
CatAI.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
CatAI.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = CatAI;
|
||||
|
||||
@@ -121,8 +121,9 @@ CatalogSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const Catalog = mongoose.model('Catalog', CatalogSchema);
|
||||
|
||||
Catalog.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Catalog.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Catalog };
|
||||
|
||||
@@ -50,9 +50,10 @@ CategorySchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const Category = mongoose.model('Category', CategorySchema);
|
||||
|
||||
Category.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Category.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
|
||||
module.exports = { Category };
|
||||
|
||||
@@ -80,8 +80,9 @@ CatGrpSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
const CatGrp = mongoose.model('CatGrp', CatGrpSchema);
|
||||
|
||||
CatGrp.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
CatGrp.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { CatGrp };
|
||||
|
||||
@@ -90,9 +90,10 @@ CatProdSchema.statics.getCatProdWithTitleCount = async function (idapp) {
|
||||
|
||||
const CatProd = mongoose.model('CatProd', CatProdSchema);
|
||||
|
||||
CatProd.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
CatProd.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
|
||||
module.exports = CatProd;
|
||||
|
||||
@@ -43,9 +43,10 @@ CfgServerSchema.statics.findAllIdApp = async function(idapp) {
|
||||
|
||||
const CfgServer = mongoose.model('CfgServer', CfgServerSchema);
|
||||
|
||||
CfgServer.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
CfgServer.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = {CfgServer};
|
||||
|
||||
|
||||
@@ -607,7 +607,7 @@ CircuitSchema.statics.getCircuitById = async function (circuitId) {
|
||||
|
||||
CircuitSchema.statics.deleteCircuit = async function (idapp, usernameOrig, name) {
|
||||
console.log('Circuito ' + name + ' rimosso da ' + usernameOrig);
|
||||
return await Circuit.findOneAndRemove({ idapp, name });
|
||||
return await Circuit.findOneAndDelete({ idapp, name });
|
||||
};
|
||||
|
||||
|
||||
@@ -1796,8 +1796,9 @@ CircuitSchema.statics.addMovementByOrdersCart = async function (ordersCart, user
|
||||
|
||||
const Circuit = mongoose.model('Circuit', CircuitSchema);
|
||||
|
||||
Circuit.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Circuit.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Circuit };
|
||||
|
||||
@@ -274,8 +274,9 @@ CitySchema.statics.insertGeojsonToMongoDB = async function (nomefilejson) {
|
||||
|
||||
const City = mongoose.model('City', CitySchema);
|
||||
|
||||
City.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
City.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { City };
|
||||
|
||||
@@ -52,6 +52,7 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
return await Collana.find(myfind).sort({title: 1}).lean();
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -47,15 +47,14 @@ ContribtypeSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Contribtype.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
}).lean();
|
||||
return await Contribtype.find(myfind).lean();
|
||||
};
|
||||
|
||||
const Contribtype = mongoose.model('Contribtype', ContribtypeSchema);
|
||||
|
||||
Contribtype.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Contribtype.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Contribtype };
|
||||
|
||||
@@ -26,9 +26,10 @@ const departmentSchema = new Schema({
|
||||
|
||||
var Department = module.exports = mongoose.model('Department', departmentSchema);
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [{ field: 'name', type: tools.FieldType.string },
|
||||
|
||||
@@ -106,8 +106,9 @@ DisciplineSchema.statics.DuplicateAllRecords = async function (idapporig, idappd
|
||||
|
||||
const Discipline = mongoose.model('Discipline', DisciplineSchema);
|
||||
|
||||
Discipline.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Discipline.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Discipline };
|
||||
|
||||
@@ -228,9 +228,8 @@ ExtraListSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await ExtraList.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await tools.findAllQueryIdApp(this, myfind);
|
||||
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
@@ -332,9 +331,10 @@ ExtraListSchema.statics.ImportData = async function (locale, idapp, strdata) {
|
||||
|
||||
const ExtraList = mongoose.model('ExtraList', ExtraListSchema);
|
||||
|
||||
ExtraList.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
ExtraList.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { ExtraList };
|
||||
|
||||
|
||||
@@ -57,15 +57,14 @@ GallerySchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Gallery.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await Gallery.find(myfind).lean();
|
||||
};
|
||||
|
||||
const Gallery = mongoose.model('Gallery', GallerySchema);
|
||||
|
||||
Gallery.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Gallery.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Gallery };
|
||||
|
||||
@@ -78,6 +78,7 @@ module.exports.getGasordineByID = function (id, callback) {
|
||||
Gasordine.findById(id, callback);
|
||||
}
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -80,8 +80,9 @@ GoodSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
const Good = mongoose.model('Good', GoodSchema);
|
||||
|
||||
Good.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Good.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Good };
|
||||
|
||||
@@ -312,9 +312,7 @@ GraduatoriaSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Graduatoria.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await Graduatoria.find(myfind).lean();
|
||||
};
|
||||
|
||||
GraduatoriaSchema.statics.isWorking = function (idapp) {
|
||||
@@ -415,8 +413,9 @@ GraduatoriaSchema.statics.getPosizioneInGraduatoria = async function (idapp, ind
|
||||
|
||||
const Graduatoria = mongoose.model('Graduatoria', GraduatoriaSchema);
|
||||
|
||||
Graduatoria.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Graduatoria.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Graduatoria };
|
||||
|
||||
@@ -47,6 +47,7 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
return await Group.find(myfind);
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -226,6 +226,7 @@ module.exports.calculateHoursTodo = async function (idtodo) {
|
||||
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -57,7 +57,10 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp, deleted: false };
|
||||
|
||||
return await ImportaDescr.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
try {
|
||||
return await ImportaDescr.find(myfind).lean();
|
||||
} catch (err) {
|
||||
console.error("Errore in ImportaDescr:", err);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -57,7 +57,10 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp, deleted: false };
|
||||
|
||||
return await ImportaIsbn.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
try {
|
||||
return await ImportaIsbn.find(myfind).lean();
|
||||
} catch (err) {
|
||||
console.error("Errore in ImportaIsbn:", err);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -57,7 +57,12 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp, deleted: false };
|
||||
|
||||
return await ImportaMacro.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
|
||||
try {
|
||||
return await ImportaMacro.find(myfind).lean();
|
||||
} catch (err) {
|
||||
console.error("Errore in ImportaMacro:", err);
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -53,7 +53,6 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp, deleted: false };
|
||||
|
||||
return await Inventariogm.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
return await tools.findAllQueryIdApp(Inventariogm, myfind);
|
||||
|
||||
};
|
||||
@@ -192,11 +192,10 @@ module.exports.findAllIdApp = async function(idapp) {
|
||||
|
||||
const myfind = {idapp};
|
||||
|
||||
return await IscrittiArcadei.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
return await tools.findAllQueryIdApp(this, myfind);
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -189,14 +189,12 @@ module.exports.findByEmail = function (idapp, email) {
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await IscrittiConacreis.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await tools.findAllQueryIdApp(this, myfind);
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -73,8 +73,9 @@ LevelSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
|
||||
const Level = mongoose.model('Level', LevelSchema);
|
||||
|
||||
Level.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Level.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = {Level};
|
||||
|
||||
@@ -36,9 +36,7 @@ MailingListSchema.statics.findAllIdAppSubscribed = function (idapp) {
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return User.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return tools.findAllQueryIdApp(User, myfind);
|
||||
};
|
||||
|
||||
MailingListSchema.statics.getnumSent = async function (idapp, idUser) {
|
||||
@@ -62,12 +60,9 @@ MailingListSchema.statics.isOk = async function (idapp, iduser, idUser) {
|
||||
|
||||
MailingListSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await User.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await tools.findAllQueryIdApp(User, myfind);
|
||||
};
|
||||
|
||||
MailingListSchema.statics.isUnsubscribed = async function (idapp, hash) {
|
||||
@@ -84,15 +79,14 @@ MailingListSchema.statics.findByHash = function (idapp, hash) {
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return User.findOne(myfind, (err, rec) => {
|
||||
return rec
|
||||
});
|
||||
return User.findOne(myfind).lean();
|
||||
};
|
||||
|
||||
const MailingList = mongoose.model('MailingList', MailingListSchema);
|
||||
|
||||
User.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
User.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MailingList };
|
||||
|
||||
@@ -72,9 +72,8 @@ MovementSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await MyMovement.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
return await tools.findAllQueryIdApp(MyMovement, myfind);
|
||||
|
||||
};
|
||||
|
||||
MovementSchema.pre('save', async function (next) {
|
||||
@@ -1069,8 +1068,9 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
|
||||
|
||||
const Movement = mongoose.model('Movement', MovementSchema);
|
||||
|
||||
Movement.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Movement.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Movement };
|
||||
|
||||
@@ -118,15 +118,15 @@ MsgTemplateSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await MsgTemplate.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await tools.findAllQueryIdApp(this, myfind);
|
||||
|
||||
};
|
||||
|
||||
const MsgTemplate = mongoose.model('MsgTemplate', MsgTemplateSchema);
|
||||
|
||||
MsgTemplate.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MsgTemplate.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MsgTemplate };
|
||||
|
||||
@@ -383,8 +383,9 @@ MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
|
||||
const MyBacheca = mongoose.model('MyBacheca', MyBachecaSchema);
|
||||
|
||||
MyBacheca.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MyBacheca.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MyBacheca };
|
||||
|
||||
@@ -532,8 +532,9 @@ MyElemSchema.statics.getNewFreeNameTemplate = async function (idapp, idPageOrig,
|
||||
|
||||
const MyElem = mongoose.model('MyElem', MyElemSchema);
|
||||
|
||||
MyElem.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MyElem.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MyElem };
|
||||
|
||||
@@ -276,8 +276,9 @@ if (tools.INITDB_FIRSTIME) {
|
||||
|
||||
const MyEvent = mongoose.model('MyEvent', MyEventSchema);
|
||||
|
||||
MyEvent.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MyEvent.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = {MyEvent};
|
||||
|
||||
@@ -367,8 +367,9 @@ MyGoodSchema.statics.getProject = function () {
|
||||
|
||||
const MyGood = mongoose.model('MyGood', MyGoodSchema);
|
||||
|
||||
MyGood.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MyGood.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MyGood };
|
||||
|
||||
@@ -378,7 +378,7 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function (idapp, groupname
|
||||
|
||||
MyGroupSchema.statics.deleteGroup = async function (idapp, usernameOrig, groupname) {
|
||||
console.log('Gruppo ' + groupname + ' rimosso da ' + usernameOrig);
|
||||
return await MyGroup.findOneAndRemove({ idapp, groupname });
|
||||
return await MyGroup.findOneAndDelete({ idapp, groupname });
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getGroupsByUsername = async function (idapp, username, req) {
|
||||
@@ -674,8 +674,9 @@ MyGroupSchema.statics.setReceiveRisGroup = async function (idapp, groupname) {
|
||||
|
||||
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
|
||||
|
||||
MyGroup.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MyGroup.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MyGroup };
|
||||
|
||||
@@ -347,17 +347,16 @@ MyHospSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
|
||||
};
|
||||
|
||||
MyHospSchema.statics.SettaAdTypeOffro_In_Hosps = function () {
|
||||
MyHospSchema.statics.SettaAdTypeOffro_In_Hosps = async function () {
|
||||
const MyHosp = this;
|
||||
|
||||
// Set all records 'adType' to shared_consts.AdType.OFFRO
|
||||
MyHosp.updateMany({}, { $set: { adType: shared_consts.AdType.OFFRO } }, function (err, result) {
|
||||
if (err) {
|
||||
console.error('Error updating adType:', err);
|
||||
} else {
|
||||
console.log('Successfully updated adType for', result.nModified, 'records');
|
||||
}
|
||||
});
|
||||
try {
|
||||
// Set all records 'adType' to shared_consts.AdType.OFFRO
|
||||
const result = await MyHosp.updateMany({}, { $set: { adType: shared_consts.AdType.OFFRO } });
|
||||
console.log('Successfully updated adType for', result.nModified, 'records');
|
||||
} catch (err) {
|
||||
console.error('Error updating adType:', err);
|
||||
}
|
||||
};
|
||||
|
||||
MyHospSchema.statics.getProject = function () {
|
||||
@@ -383,8 +382,9 @@ MyHospSchema.statics.getProject = function () {
|
||||
|
||||
const MyHosp = mongoose.model('MyHosp', MyHospSchema);
|
||||
|
||||
MyHosp.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MyHosp.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MyHosp };
|
||||
|
||||
@@ -164,9 +164,13 @@ MyPageSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await MyPage.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
}).sort({ title: 1 }).lean();
|
||||
try {
|
||||
return await MyPage.find(myfind).sort({ title: 1 }).lean();
|
||||
} catch (err) {
|
||||
console.error("Errore in MyPage:", err, model);
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MyPageSchema.statics.findOnlyStruttRec = async function (idapp) {
|
||||
@@ -176,9 +180,15 @@ MyPageSchema.statics.findOnlyStruttRec = async function (idapp) {
|
||||
{
|
||||
idapp,
|
||||
loadFirst: true,
|
||||
},
|
||||
(err, arrrec) => {
|
||||
return arrrec
|
||||
}).then(
|
||||
(arrrec) => {
|
||||
return arrrec
|
||||
}
|
||||
).catch((err) => {
|
||||
if (err) {
|
||||
console.error('findOnlyStruttRec', err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
const arrfixed = await MyPage.find(
|
||||
@@ -206,8 +216,14 @@ MyPageSchema.statics.findOnlyStruttRec = async function (idapp) {
|
||||
loadFirst: 1,
|
||||
mainMenu: 1,
|
||||
sottoMenu: 1,
|
||||
}, (err, arrrec) => {
|
||||
}).then((arrrec) => {
|
||||
return arrrec
|
||||
}).catch((err) => {
|
||||
if (err) {
|
||||
console.error('findOnlyStruttRec', err);
|
||||
throw err;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return [...arrFirst, ...arrfixed];
|
||||
@@ -217,25 +233,32 @@ MyPageSchema.statics.findOnlyStruttRec = async function (idapp) {
|
||||
MyPageSchema.statics.findInternalPages = async function (idapp) {
|
||||
const MyPage = this;
|
||||
|
||||
const myfind = {
|
||||
idapp,
|
||||
internalpage: { $exists: true, $eq: true }
|
||||
};
|
||||
try {
|
||||
const myfind = {
|
||||
idapp,
|
||||
internalpage: { $exists: true, $eq: true }
|
||||
};
|
||||
|
||||
return await MyPage.find(myfind, {
|
||||
title: 1,
|
||||
path: 1,
|
||||
onlyif_logged: 1,
|
||||
only_residenti: 1,
|
||||
}, (err, arrrec) => {
|
||||
return arrrec
|
||||
}).lean();
|
||||
const result = await MyPage.find(myfind, {
|
||||
title: 1,
|
||||
path: 1,
|
||||
onlyif_logged: 1,
|
||||
only_residenti: 1,
|
||||
}).lean();
|
||||
|
||||
return result;
|
||||
|
||||
} catch (err) {
|
||||
console.log('findInternalPages', err);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
const MyPage = mongoose.model('MyPage', MyPageSchema);
|
||||
|
||||
MyPage.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MyPage.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MyPage };
|
||||
|
||||
@@ -158,8 +158,9 @@ MySchedaSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const MyScheda = mongoose.model('MyScheda', MySchedaSchema);
|
||||
|
||||
MyScheda.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MyScheda.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MyScheda, MySchedaSchema, IDimensioni, IImg, IText, IAreaDiStampa, IImg };
|
||||
|
||||
@@ -373,8 +373,9 @@ MySkillSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
|
||||
const MySkill = mongoose.model('MySkill', MySkillSchema);
|
||||
|
||||
MySkill.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
MySkill.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { MySkill };
|
||||
|
||||
@@ -140,9 +140,8 @@ NewstosentSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return await Newstosent.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await tools.findAllQueryIdApp(this, myfind);
|
||||
|
||||
};
|
||||
|
||||
NewstosentSchema.statics.getlast = async function (idapp) {
|
||||
@@ -170,8 +169,9 @@ NewstosentSchema.statics.isActivated = async function (_id) {
|
||||
|
||||
const Newstosent = mongoose.model('Newstosent', NewstosentSchema);
|
||||
|
||||
Newstosent.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Newstosent.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Newstosent };
|
||||
|
||||
@@ -104,22 +104,15 @@ OperatorSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
};
|
||||
|
||||
OperatorSchema.statics.findAllIdApp = function (idapp) {
|
||||
const Operator = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
|
||||
return Operator.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
const query = this.find({ idapp }); // Crea la query
|
||||
return query.exec(); // Esegui la query come promessa
|
||||
};
|
||||
|
||||
const Operator = mongoose.model('Operator', OperatorSchema);
|
||||
|
||||
Operator.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Operator.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Operator };
|
||||
|
||||
@@ -35,16 +35,15 @@ OpzEmailSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
OpzEmailSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const OpzEmail = this;
|
||||
|
||||
return await OpzEmail.find({}, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await tools.findAllQueryIdApp(this, {});
|
||||
};
|
||||
|
||||
|
||||
const OpzEmail = mongoose.model('OpzEmail', OpzEmailSchema);
|
||||
|
||||
OpzEmail.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
OpzEmail.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { OpzEmail };
|
||||
|
||||
@@ -131,9 +131,10 @@ const orderSchema = new Schema({
|
||||
|
||||
var Order = module.exports = mongoose.model('Order', orderSchema);
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return []
|
||||
@@ -377,7 +378,7 @@ module.exports.updateTotals = function (order) {
|
||||
|
||||
module.exports.getTotalOrderById = async function (id) {
|
||||
const query = [
|
||||
{ $match: { _id: ObjectId(id) } },
|
||||
{ $match: { _id: new ObjectId(id) } },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'products',
|
||||
@@ -642,7 +643,7 @@ module.exports.RemoveDeletedOrdersInOrderscart = async function () {
|
||||
if (!orderCart) {
|
||||
// NON TROVATO ! Allora lo cancello
|
||||
|
||||
await Order.findOneAndRemove({ _id: ord._id });
|
||||
await Order.findOneAndDelete({ _id: ord._id });
|
||||
}
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
@@ -660,7 +661,7 @@ module.exports.GeneraCSVOrdineProdotti = async function () {
|
||||
const myidGasordine = '65c2a8cc379ee4f57e865ee7';
|
||||
|
||||
const myquery = [
|
||||
{ $match: { idGasordine: ObjectId(myidGasordine) } },
|
||||
{ $match: { idGasordine: new ObjectId(myidGasordine) } },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'products',
|
||||
|
||||
@@ -198,7 +198,7 @@ module.exports.getRecCartByUserId = async function (uid, idapp, numorder) {
|
||||
|
||||
module.exports.getOrdersCartById = async function (id) {
|
||||
|
||||
let query = { _id: ObjectId(id) };
|
||||
let query = { _id: new ObjectId(id) };
|
||||
|
||||
const arrris = await OrdersCart.getOrdersCartByQuery(query);
|
||||
let myrec = arrris && arrris.length > 0 ? arrris[0] : null;
|
||||
@@ -543,41 +543,44 @@ module.exports.getOrdersCartByUserId = async function (uid, idapp, numorder, fil
|
||||
}
|
||||
|
||||
|
||||
module.exports.updateOrdersCartById = function (id, newOrdersCart, callback) {
|
||||
module.exports.updateOrdersCartById = async function(id, newOrdersCart, callback) {
|
||||
let query = {
|
||||
id,
|
||||
deleted: false,
|
||||
}
|
||||
OrdersCart.find(query, function (err, c) {
|
||||
if (err) throw err
|
||||
try {
|
||||
const c = await OrdersCart.find(query);
|
||||
} catch (err) {
|
||||
console.log('ERR: updateOrdersCartById', err);
|
||||
if (err) throw err;
|
||||
}
|
||||
|
||||
//exist cart in databse
|
||||
if (c.length > 0) {
|
||||
return OrdersCart.findOneAndUpdate(
|
||||
{ _id: id },
|
||||
{
|
||||
$set: {
|
||||
items: newOrdersCart.items,
|
||||
totalQty: newOrdersCart.totalQty,
|
||||
totalQtyPreordered: newOrdersCart.totalQtyPreordered,
|
||||
totalPrice: newOrdersCart.totalPrice,
|
||||
totalPriceCalc: newOrdersCart.totalPriceCalc ? newOrdersCart.totalPriceCalc : newOrdersCart.totalPrice,
|
||||
userId: userId,
|
||||
status: newOrdersCart.status,
|
||||
numorder: newOrdersCart.numorder,
|
||||
numord_pers: newOrdersCart.numord_pers,
|
||||
note: newOrdersCart.note,
|
||||
modify_at: new Date(),
|
||||
}
|
||||
},
|
||||
{ new: true },
|
||||
callback
|
||||
)
|
||||
} else {
|
||||
//no cart in database
|
||||
return newOrdersCart.save(callback)
|
||||
}
|
||||
})
|
||||
//exist cart in databse
|
||||
if (c.length > 0) {
|
||||
return OrdersCart.findOneAndUpdate(
|
||||
{ _id: id },
|
||||
{
|
||||
$set: {
|
||||
items: newOrdersCart.items,
|
||||
totalQty: newOrdersCart.totalQty,
|
||||
totalQtyPreordered: newOrdersCart.totalQtyPreordered,
|
||||
totalPrice: newOrdersCart.totalPrice,
|
||||
totalPriceCalc: newOrdersCart.totalPriceCalc ? newOrdersCart.totalPriceCalc : newOrdersCart.totalPrice,
|
||||
userId: userId,
|
||||
status: newOrdersCart.status,
|
||||
numorder: newOrdersCart.numorder,
|
||||
numord_pers: newOrdersCart.numord_pers,
|
||||
note: newOrdersCart.note,
|
||||
modify_at: new Date(),
|
||||
}
|
||||
},
|
||||
{ new: true },
|
||||
callback
|
||||
)
|
||||
} else {
|
||||
//no cart in database
|
||||
return newOrdersCart.save(callback)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.setFieldInOrdersById = async function (objtoset, myOrderCart) {
|
||||
@@ -616,10 +619,10 @@ module.exports.deleteRecsInOrdersById = async function (myOrderCart) {
|
||||
let ris2 = null;
|
||||
// Imposta su tutti i singoli prodotti ordinati (Order)
|
||||
for (const recitem of myOrderCart.items) {
|
||||
ris2 = await Order.findOneAndRemove({ _id: recitem.order._id })
|
||||
ris2 = await Order.findOneAndDelete({ _id: recitem.order._id })
|
||||
}
|
||||
|
||||
const ris = await OrdersCart.findOneAndRemove({ _id: myOrderCart._id })
|
||||
const ris = await OrdersCart.findOneAndDelete({ _id: myOrderCart._id })
|
||||
|
||||
} catch (e) {
|
||||
console.log('Err', e);
|
||||
@@ -1045,19 +1048,6 @@ OrdersCartSchema.pre('save', async function (next) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (user.isModified('password')) {
|
||||
bcrypt.genSalt(10, (err, salt) => {
|
||||
bcrypt.hash(user.password, salt, (err, hash) => {
|
||||
user.password = hash;
|
||||
next();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
*/
|
||||
|
||||
next();
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
@@ -1171,6 +1161,7 @@ module.exports.getmsgorderTelegram = async function (ordersCart) {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -38,15 +38,15 @@ PaymentTypeSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await PaymentType.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await tools.findAllQueryIdApp(this, myfind);
|
||||
|
||||
};
|
||||
|
||||
const PaymentType = mongoose.model('Paymenttype', PaymentTypeSchema);
|
||||
|
||||
PaymentType.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
PaymentType.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { PaymentType };
|
||||
|
||||
@@ -50,15 +50,14 @@ PermissionSchema.statics.findAllIdApp = async function () {
|
||||
|
||||
const myfind = {};
|
||||
|
||||
return await Permission.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await tools.findAllQueryIdApp(this, {});
|
||||
};
|
||||
|
||||
const Permission = mongoose.model('Permission', PermissionSchema);
|
||||
|
||||
Permission.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Permission.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Permission };
|
||||
|
||||
@@ -101,6 +101,7 @@ module.exports.getProducerByID = function (id, callback) {
|
||||
|
||||
// module.exports = { Producer };
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -764,9 +764,10 @@ module.exports.updateProductInOrder = async function (order) {
|
||||
return order;
|
||||
}
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports.convertAfterImportALLPROD = async function (idapp, dataObjects) {
|
||||
|
||||
@@ -841,18 +842,16 @@ module.exports.getArrCatProds = async function (idapp, cosa) {
|
||||
{ $sort: { name: 1 } }
|
||||
];
|
||||
|
||||
arr = await Product.aggregate(myquery, (err, result) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
// Gestisci l'errore come desideri
|
||||
return [];
|
||||
} else {
|
||||
const uniqueCategories = result.map(category => category.name);
|
||||
// console.log(uniqueCategories);
|
||||
return uniqueCategories;
|
||||
// Ora uniqueCategories contiene l'array delle categorie univoche utilizzate in tutti i prodotti con active = true
|
||||
}
|
||||
});
|
||||
try {
|
||||
let arr = [];
|
||||
const result = await Product.aggregate(myquery);
|
||||
|
||||
arr = result.map(category => category.name);
|
||||
return arr;
|
||||
} catch (e) {
|
||||
console.error('err', e);
|
||||
}
|
||||
// Ora uniqueCategories contiene l'array delle categorie univoche utilizzate in tutti i prodotti con active = true
|
||||
return arr;
|
||||
} catch (e) {
|
||||
console.error('err', e);
|
||||
@@ -1015,7 +1014,7 @@ module.exports.singlerecconvert_AfterImport_AndSave = async function (idapp, pro
|
||||
}
|
||||
|
||||
if (!tools.isObjectEmpty(objtoset)) {
|
||||
ris = await Product.findOneAndUpdate({ _id: ObjectId(prod._id) }, { $set: objtoset })
|
||||
ris = await Product.findOneAndUpdate({ _id: new ObjectId(prod._id) }, { $set: objtoset })
|
||||
|
||||
const objDelete = {
|
||||
cat_name: 1,
|
||||
@@ -1028,7 +1027,7 @@ module.exports.singlerecconvert_AfterImport_AndSave = async function (idapp, pro
|
||||
gas_name: 1,
|
||||
};
|
||||
|
||||
ris = await Product.updateOne({ _id: ObjectId(prod._id) }, { $unset: objDelete })
|
||||
ris = await Product.updateOne({ _id: new ObjectId(prod._id) }, { $unset: objDelete })
|
||||
|
||||
if (ris && ris.nModified > 0) {
|
||||
console.log('Modificato: ', objtoset.name);
|
||||
|
||||
@@ -440,6 +440,7 @@ module.exports.correggiProductTypes = async function () {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ ProjectSchema.statics.getIdParentByIdProj = function (idProj) {
|
||||
|
||||
console.log('INIT getIdParentByIdProj', idProj);
|
||||
|
||||
return Project.findOne({ '_id': ObjectId(idProj) }).then(rec => {
|
||||
return Project.findOne({ '_id': new ObjectId(idProj) }).then(rec => {
|
||||
if (!!rec) {
|
||||
console.log('getIdParentByIdProj', rec.id_parent);
|
||||
return rec.id_parent;
|
||||
@@ -428,9 +428,10 @@ ProjectSchema.pre('save', function (next) {
|
||||
|
||||
var Project = mongoose.model('Projects', ProjectSchema);
|
||||
|
||||
Project.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Project.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Project };
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
return await Provider.find(myfind);
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -152,8 +152,9 @@ ProvinceSchema.statics.setCoordinatesOnDB = async function () {
|
||||
|
||||
const Province = mongoose.model('Province', ProvinceSchema);
|
||||
|
||||
Province.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Province.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Province };
|
||||
|
||||
@@ -45,6 +45,7 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
return await Publisher.find(myfind).sort({ name: 1 }).lean();
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -81,8 +81,9 @@ QueryAISchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
const QueryAI = mongoose.model('QueryAI', QueryAISchema);
|
||||
|
||||
QueryAI.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
QueryAI.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { QueryAI };
|
||||
|
||||
@@ -433,8 +433,9 @@ reactionSchema.statics.removeBookmark = async function (
|
||||
|
||||
const Reaction = mongoose.model('Reaction', reactionSchema);
|
||||
|
||||
Reaction.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Reaction.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Reaction };
|
||||
|
||||
@@ -57,6 +57,7 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
return await Scontistica.find(myfind);
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -38,16 +38,15 @@ searchSchema.statics.findAllByUserIdAndIdApp = function (userId, idapp, sall) {
|
||||
else
|
||||
myfind = { userId, idapp };
|
||||
|
||||
return Search.find(myfind, (err, arrsearch) => {
|
||||
return arrsearch
|
||||
});
|
||||
return Search.find(myfind).lean();
|
||||
};
|
||||
|
||||
|
||||
const Search = mongoose.model('Search', searchSchema);
|
||||
|
||||
Search.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Search.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Search };
|
||||
|
||||
@@ -80,8 +80,9 @@ SectorActivitiesSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
const SectorActivities = mongoose.model('SectorActivities', SectorActivitiesSchema);
|
||||
|
||||
SectorActivities.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
SectorActivities.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { SectorActivities };
|
||||
|
||||
@@ -80,8 +80,9 @@ SectorGoodSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
const SectorGood = mongoose.model('SectorGood', SectorGoodSchema);
|
||||
|
||||
SectorGood.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
SectorGood.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { SectorGood };
|
||||
|
||||
@@ -109,8 +109,9 @@ sendmsgSchema.statics.findLastGroupByUserIdAndIdApp = function (userId, username
|
||||
|
||||
const SendMsg = mongoose.model('SendMsg', sendmsgSchema);
|
||||
|
||||
SendMsg.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
SendMsg.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { SendMsg };
|
||||
|
||||
@@ -1383,8 +1383,9 @@ sendNotifSchema.statics.checkIfAlreadyExist = async function (idapp, tag, idpost
|
||||
|
||||
const SendNotif = mongoose.model('SendNotif', sendNotifSchema);
|
||||
|
||||
SendNotif.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
SendNotif.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { SendNotif: SendNotif };
|
||||
|
||||
@@ -178,8 +178,9 @@ SettingsSchema.statics.getKeyNum = async function (idapp, key, mydefault) {
|
||||
|
||||
const Settings = mongoose.model('Settings', SettingsSchema);
|
||||
|
||||
Settings.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Settings.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Settings };
|
||||
|
||||
@@ -47,6 +47,7 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
return await ShareWithUs.find(myfind);
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@ module.exports.executeQueryTable = async function (idapp, params, userreq) {
|
||||
|
||||
if (myarr.length === 0) {
|
||||
/* {
|
||||
"_id" : ObjectId("620a71e194438ecd1acfdbca"),
|
||||
"_id" : new ObjectId("620a71e194438ecd1acfdbca"),
|
||||
"idapp" : "14",
|
||||
"chiave" : "vers",
|
||||
"userId" : "ALL",
|
||||
@@ -429,6 +429,7 @@ module.exports.createFirstUserAdmin = async function () {
|
||||
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -78,8 +78,9 @@ SkillSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
const Skill = mongoose.model('Skill', SkillSchema);
|
||||
|
||||
Skill.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Skill.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Skill };
|
||||
|
||||
@@ -172,8 +172,9 @@ StatSchema.statics.getStats = async function (idapp) {
|
||||
|
||||
const Stat = mongoose.model('Stat', StatSchema);
|
||||
|
||||
Stat.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Stat.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Stat };
|
||||
|
||||
@@ -75,8 +75,9 @@ StatusSkillSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
const StatusSkill = mongoose.model('StatusSkill', StatusSkillSchema);
|
||||
|
||||
StatusSkill.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
StatusSkill.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { StatusSkill };
|
||||
|
||||
@@ -98,6 +98,7 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
return await Storehouse.find(myfind);
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -60,9 +60,10 @@ SubCatProdSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const SubCatProd = mongoose.model('SubCatProd', SubCatProdSchema);
|
||||
|
||||
SubCatProd.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
SubCatProd.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
|
||||
module.exports = SubCatProd;
|
||||
|
||||
@@ -26,6 +26,7 @@ const SubscriberSchema = new Schema({
|
||||
|
||||
var Subscription = module.exports = mongoose.model('subscribers', SubscriberSchema);
|
||||
|
||||
Subscription.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Subscription.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
@@ -78,8 +78,9 @@ SubSkillSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
const SubSkill = mongoose.model('SubSkill', SubSkillSchema);
|
||||
|
||||
SubSkill.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
SubSkill.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { SubSkill };
|
||||
|
||||
@@ -67,8 +67,9 @@ TemplEmailSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const TemplEmail = mongoose.model('TemplEmail', TemplEmailSchema);
|
||||
|
||||
TemplEmail.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
TemplEmail.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { TemplEmail };
|
||||
|
||||
@@ -108,7 +108,7 @@ TodoSchema.statics.findByUserIdAndIdParent = function (userId, category, phase =
|
||||
var Todo = this;
|
||||
|
||||
let tofind = {
|
||||
category: ObjectId(category),
|
||||
category: new ObjectId(category),
|
||||
$or:
|
||||
[{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
|
||||
|
||||
@@ -126,9 +126,6 @@ TodoSchema.statics.findByUserIdAndIdParent = function (userId, category, phase =
|
||||
|
||||
};
|
||||
|
||||
// User.find({ admin: true }).where('created_at').gt(monthAgo).exec(function(err, users) {
|
||||
// if (err) throw err;
|
||||
|
||||
function getQueryFilterTodo(userId) {
|
||||
let myobj = [
|
||||
// { userId: userId },
|
||||
@@ -225,7 +222,7 @@ TodoSchema.statics.enabletoModify = async function (userId, idTodo) {
|
||||
var Todo = this;
|
||||
|
||||
let params = {};
|
||||
params['_id'] = ObjectId(idTodo);
|
||||
params['_id'] = new ObjectId(idTodo);
|
||||
const query = getQueryTodo(params, userId);
|
||||
|
||||
return Todo.aggregate(query)
|
||||
@@ -519,9 +516,10 @@ TodoSchema.pre('save', function (next) {
|
||||
|
||||
var Todo = mongoose.model('Todos', TodoSchema);
|
||||
|
||||
Todo.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Todo.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Todo };
|
||||
|
||||
|
||||
@@ -771,7 +771,9 @@ UserSchema.statics.findByToken = async function (token, typeaccess, con_auth) {
|
||||
check_expiry_date = true
|
||||
}
|
||||
|
||||
if (check_expiry_date && (decoded.exp < Date.now() / 1000)) {
|
||||
let tempo = Date.now() / 1000;
|
||||
|
||||
if (check_expiry_date && (decoded.exp < tempo)) {
|
||||
console.log('Il token è scaduto, generazione del nuovo token...');
|
||||
code = server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED;
|
||||
} else {
|
||||
@@ -4227,9 +4229,7 @@ UserSchema.statics.findAllIdApp = async function (idapp) {
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
};
|
||||
|
||||
return await User.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
return await tools.findAllQueryIdApp(this, myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
@@ -4307,26 +4307,6 @@ UserSchema.statics.getDownline = async function (
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
UserSchema.statics.fixUsername = async function (idapp, aportador_solidario_ind_order, username) {
|
||||
const User = this;
|
||||
|
||||
// Check if somewhere there is my username
|
||||
return User.find({ idapp, aportador_solidario_ind_order }, async (err, arrrec) => {
|
||||
if (arrrec) {
|
||||
for (const myuser of arrrec) {
|
||||
if (!myuser.aportador_solidario || myuser.aportador_solidario === tools.APORTADOR_NONE) {
|
||||
myuser.aportador_solidario = username;
|
||||
await myuser.save()
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
UserSchema.statics.findByCellAndNameSurname = function (
|
||||
idapp, cell, name, surname) {
|
||||
const User = this;
|
||||
@@ -6324,9 +6304,10 @@ UserSchema.statics.createNewSubRecord = async function (idapp, req) {
|
||||
|
||||
const User = mongoose.model('User', UserSchema);
|
||||
|
||||
User.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
User.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
class Hero {
|
||||
constructor(name, level) {
|
||||
|
||||
@@ -95,8 +95,9 @@ UserRequestSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const UserRequest = mongoose.model('UserRequest', UserRequestSchema);
|
||||
|
||||
UserRequest.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
UserRequest.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { UserRequest };
|
||||
|
||||
@@ -44,15 +44,14 @@ WhereSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Where.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return await Where.find(myfind).lean();
|
||||
};
|
||||
|
||||
const Where = mongoose.model('Where', WhereSchema);
|
||||
|
||||
Where.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
Where.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
|
||||
module.exports = { Where };
|
||||
|
||||
@@ -2,25 +2,25 @@ const { ObjectId } = require('mongodb');
|
||||
|
||||
module.exports = {
|
||||
list: [
|
||||
/*{ _id: ObjectId('605c72e2f9b1a019c1e4f4a1'), idapp: '18', title: 'Alimentazione Sana' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4a2'), idapp: '18', title: 'Attualità e Informazione Libera' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4a3'), idapp: '18', title: 'Psicologia e Crescita Personale' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4a4'), idapp: '18', title: 'Educazione e Formazione' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4a5'), idapp: '18', title: 'Bambini e Ragazzi Felici' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4a6'), idapp: '18', title: 'Salute e Benessere Naturali' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4a7'), idapp: '18', title: 'Nuove Scienze' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4a8'), idapp: '18', title: 'Spiritualità e Sciamanesimo' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4a9'), idapp: '18', title: 'Storia e Archeologia Segreta' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4aa'), idapp: '18', title: 'Autosufficienza, Autoproduzione e Vita Naturale' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4ab'), idapp: '18', title: 'Yoga' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4ac'), idapp: '18', title: 'Amici Animali' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4ad'), idapp: '18', title: 'Corpi Energetici' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4ae'), idapp: '18', title: 'Erbe, Alberi e Natura' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4af'), idapp: '18', title: 'Astrologia, Esoterismi e Numerologia' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4b0'), idapp: '18', title: 'Universo Femminile' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4b1'), idapp: '18', title: 'Sessualità e Relazione di coppia' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4b2'), idapp: '18', title: 'Tarocchi, Oracoli e Carte' },
|
||||
{ _id: ObjectId('605c72e2f9b1a019c1e4f4b3'), idapp: '18', title: 'Techiche per il corpo' },
|
||||
/*{ _id: new ObjectId('605c72e2f9b1a019c1e4f4a1'), idapp: '18', title: 'Alimentazione Sana' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4a2'), idapp: '18', title: 'Attualità e Informazione Libera' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4a3'), idapp: '18', title: 'Psicologia e Crescita Personale' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4a4'), idapp: '18', title: 'Educazione e Formazione' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4a5'), idapp: '18', title: 'Bambini e Ragazzi Felici' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4a6'), idapp: '18', title: 'Salute e Benessere Naturali' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4a7'), idapp: '18', title: 'Nuove Scienze' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4a8'), idapp: '18', title: 'Spiritualità e Sciamanesimo' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4a9'), idapp: '18', title: 'Storia e Archeologia Segreta' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4aa'), idapp: '18', title: 'Autosufficienza, Autoproduzione e Vita Naturale' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4ab'), idapp: '18', title: 'Yoga' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4ac'), idapp: '18', title: 'Amici Animali' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4ad'), idapp: '18', title: 'Corpi Energetici' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4ae'), idapp: '18', title: 'Erbe, Alberi e Natura' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4af'), idapp: '18', title: 'Astrologia, Esoterismi e Numerologia' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4b0'), idapp: '18', title: 'Universo Femminile' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4b1'), idapp: '18', title: 'Sessualità e Relazione di coppia' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4b2'), idapp: '18', title: 'Tarocchi, Oracoli e Carte' },
|
||||
{ _id: new ObjectId('605c72e2f9b1a019c1e4f4b3'), idapp: '18', title: 'Techiche per il corpo' },
|
||||
*/
|
||||
],
|
||||
};
|
||||
@@ -3,90 +3,90 @@ const { ObjectId } = require('mongodb');
|
||||
module.exports = {
|
||||
list: [
|
||||
{
|
||||
"_id": ObjectId("615a353c002c8298f4495be7"),
|
||||
"_id": new ObjectId("615a353c002c8298f4495be7"),
|
||||
"idapp": "1",
|
||||
"label": "Dono",
|
||||
"__v": 0
|
||||
},
|
||||
|
||||
{
|
||||
"_id": ObjectId("61bc466567de9a1f54b25494"),
|
||||
"_id": new ObjectId("61bc466567de9a1f54b25494"),
|
||||
"idapp": "1",
|
||||
"label": "Offerta Libera",
|
||||
"__v": 0
|
||||
},
|
||||
|
||||
{
|
||||
"_id": ObjectId("61bc454867de9a1f54b25462"),
|
||||
"_id": new ObjectId("61bc454867de9a1f54b25462"),
|
||||
"idapp": "1",
|
||||
"label": "Baratto (scambio Beni o Servizi)",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("61bc482667de9a1f54b2549c"),
|
||||
"_id": new ObjectId("61bc482667de9a1f54b2549c"),
|
||||
"idapp": "1",
|
||||
"label": "Scambio Lavoro",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("61bc482667de9a1f54b2649c"),
|
||||
"_id": new ObjectId("61bc482667de9a1f54b2649c"),
|
||||
"idapp": "1",
|
||||
"label": "Monete Alternative",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("61bc482667de9a1f54b3549e"),
|
||||
"_id": new ObjectId("61bc482667de9a1f54b3549e"),
|
||||
"idapp": "1",
|
||||
"label": "Euro",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("615a353c002c8298f4495bf7"),
|
||||
"_id": new ObjectId("615a353c002c8298f4495bf7"),
|
||||
"idapp": "12",
|
||||
"label": "Dono",
|
||||
"__v": 0
|
||||
},
|
||||
|
||||
{
|
||||
"_id": ObjectId("61bc466567de9a1f54b254f4"),
|
||||
"_id": new ObjectId("61bc466567de9a1f54b254f4"),
|
||||
"idapp": "12",
|
||||
"label": "Offerta Libera",
|
||||
"__v": 0
|
||||
},
|
||||
|
||||
{
|
||||
"_id": ObjectId("61bc454867de9a1f54b254f2"),
|
||||
"_id": new ObjectId("61bc454867de9a1f54b254f2"),
|
||||
"idapp": "12",
|
||||
"label": "Baratto",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("61bc482667de9a1f54b25412"),
|
||||
"_id": new ObjectId("61bc482667de9a1f54b25412"),
|
||||
"idapp": "12",
|
||||
"label": "Scambio Lavoro",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("61bc482667de9a1f64b254ab"),
|
||||
"_id": new ObjectId("61bc482667de9a1f64b254ab"),
|
||||
"idapp": "12",
|
||||
"label": "Monete Alternative",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("61bc482667de9a1f64b254fb"),
|
||||
"_id": new ObjectId("61bc482667de9a1f64b254fb"),
|
||||
"idapp": "12",
|
||||
"label": "Euro",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("5dbc6b0801234f629f75e98d"),
|
||||
"_id": new ObjectId("5dbc6b0801234f629f75e98d"),
|
||||
"idapp": "2",
|
||||
"__v": 0,
|
||||
"label": "Offerta Libera"
|
||||
},
|
||||
/* 2 */
|
||||
{
|
||||
"_id": ObjectId("5dbc6b1001234f629f75e98e"),
|
||||
"_id": new ObjectId("5dbc6b1001234f629f75e98e"),
|
||||
"idapp": "2",
|
||||
"__v": 0,
|
||||
"label": "Ingresso Gratuito"
|
||||
@@ -94,7 +94,7 @@ module.exports = {
|
||||
|
||||
/* 3 */
|
||||
{
|
||||
"_id": ObjectId("5dbc6b1801234f629f75e98f"),
|
||||
"_id": new ObjectId("5dbc6b1801234f629f75e98f"),
|
||||
"idapp": "2",
|
||||
"__v": 0,
|
||||
"label": "Contributo",
|
||||
@@ -103,13 +103,13 @@ module.exports = {
|
||||
|
||||
/* 4 */
|
||||
{
|
||||
"_id": ObjectId("5dbc6b3001234f629f75e990"),
|
||||
"_id": new ObjectId("5dbc6b3001234f629f75e990"),
|
||||
"idapp": "2",
|
||||
"__v": 0
|
||||
},
|
||||
|
||||
{
|
||||
"_id": ObjectId("602c315137d9f0738ded312f"),
|
||||
"_id": new ObjectId("602c315137d9f0738ded312f"),
|
||||
"idapp": "10",
|
||||
"__v": 0,
|
||||
"label": "Contributo",
|
||||
@@ -118,7 +118,7 @@ module.exports = {
|
||||
|
||||
/* 7 */
|
||||
{
|
||||
"_id": ObjectId("602c316037d9f0738ded3132"),
|
||||
"_id": new ObjectId("602c316037d9f0738ded3132"),
|
||||
"idapp": "10",
|
||||
"__v": 0,
|
||||
"label": "Gratuito"
|
||||
@@ -126,61 +126,61 @@ module.exports = {
|
||||
|
||||
/* 8 */
|
||||
{
|
||||
"_id": ObjectId("60514b3f733ce468d09366f2"),
|
||||
"_id": new ObjectId("60514b3f733ce468d09366f2"),
|
||||
"idapp": "10",
|
||||
"__v": 0,
|
||||
"label": "Evento ONLINE Gratuito"
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("515a353c002c8298f4495bf7"),
|
||||
"_id": new ObjectId("515a353c002c8298f4495bf7"),
|
||||
"idapp": "13",
|
||||
"label": "🎁 Dono",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc466567de9a1f54b254f4"),
|
||||
"_id": new ObjectId("51bc466567de9a1f54b254f4"),
|
||||
"idapp": "13",
|
||||
"label": "💸 Offerta Libera",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc454867de9a1f54b254f2"),
|
||||
"_id": new ObjectId("51bc454867de9a1f54b254f2"),
|
||||
"idapp": "13",
|
||||
"label": "🤝 Baratto",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f54b25412"),
|
||||
"_id": new ObjectId("51bc482667de9a1f54b25412"),
|
||||
"idapp": "13",
|
||||
"label": "💪 Scambio Lavoro",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f64b254ab"),
|
||||
"_id": new ObjectId("51bc482667de9a1f64b254ab"),
|
||||
"idapp": "13",
|
||||
"label": "🪙 Monete Alternative",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f64b254ac"),
|
||||
"_id": new ObjectId("51bc482667de9a1f64b254ac"),
|
||||
"idapp": "13",
|
||||
"label": "🍚 RIS",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f64b254fb"),
|
||||
"_id": new ObjectId("51bc482667de9a1f64b254fb"),
|
||||
"idapp": "13",
|
||||
"label": "💶 Euro",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f64b254ff"),
|
||||
"_id": new ObjectId("51bc482667de9a1f64b254ff"),
|
||||
"idapp": "13",
|
||||
"label": "₿ Bitcoin",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f64b255ff"),
|
||||
"_id": new ObjectId("51bc482667de9a1f64b255ff"),
|
||||
"idapp": "13",
|
||||
"label": "⏳ Banca del Tempo",
|
||||
"__v": 0
|
||||
|
||||
@@ -144,7 +144,6 @@ module.exports = {
|
||||
await mytab.collection.drop();
|
||||
// mongoose.connection.db.dropCollection(table, function(err) {
|
||||
console.log('Delete ', table);
|
||||
// await mytab.remove({});
|
||||
|
||||
this.insertIntoDb_NoDuplicate(false, table, mytab, field);
|
||||
// });
|
||||
|
||||
@@ -3,7 +3,7 @@ const { ObjectId } = require('mongodb');
|
||||
module.exports = {
|
||||
list: [
|
||||
{
|
||||
_id: ObjectId("115a353c002c298f44900010"),
|
||||
_id: new ObjectId("115a353c002c298f44900010"),
|
||||
idapp: 18,
|
||||
ask: [
|
||||
{ descr: 'Scegli quanti punti', value: 'numpunti' },
|
||||
@@ -13,7 +13,7 @@ module.exports = {
|
||||
output_type: 'ELENCO',
|
||||
},
|
||||
{
|
||||
_id: ObjectId("115a353c002c298f44900020"),
|
||||
_id: new ObjectId("115a353c002c298f44900020"),
|
||||
idapp: 18,
|
||||
ask: [
|
||||
{ descr: 'Numeri di righe', value: 'numrighe', min: 1, max: 100 },
|
||||
@@ -23,7 +23,7 @@ module.exports = {
|
||||
output_type: 'ELENCO',
|
||||
},
|
||||
{
|
||||
_id: ObjectId("115a353c002c829f44900030"),
|
||||
_id: new ObjectId("115a353c002c829f44900030"),
|
||||
idapp: 18,
|
||||
ask: [],
|
||||
descr: 'Estrai le cose importanti dell\'articolo',
|
||||
@@ -31,7 +31,7 @@ module.exports = {
|
||||
output_type: '',
|
||||
},
|
||||
{
|
||||
_id: ObjectId("115a353c002c8298f4900040"),
|
||||
_id: new ObjectId("115a353c002c8298f4900040"),
|
||||
idapp: 18,
|
||||
ask: [],
|
||||
descr: 'Dammi degli Emoji',
|
||||
@@ -40,7 +40,7 @@ module.exports = {
|
||||
output_type: '',
|
||||
},
|
||||
{
|
||||
_id: ObjectId("115a353c002c298f44900050"),
|
||||
_id: new ObjectId("115a353c002c298f44900050"),
|
||||
idapp: 18,
|
||||
ask: [
|
||||
{ descr: 'Scegli quanti Punti', value: 'numpunti' },
|
||||
@@ -50,13 +50,13 @@ module.exports = {
|
||||
output_type: 'ELENCO',
|
||||
},
|
||||
{
|
||||
_id: ObjectId("115a353c002c898f44900060"),
|
||||
_id: new ObjectId("115a353c002c898f44900060"),
|
||||
idapp: 18,
|
||||
descr: 'Scaletta punti',
|
||||
query: 'Mi fai una scaletta di punti che potrei affrontare durante il webinar.',
|
||||
},
|
||||
{
|
||||
_id: ObjectId("115a353c002c829f44900070"),
|
||||
_id: new ObjectId("115a353c002c829f44900070"),
|
||||
idapp: 18,
|
||||
descr: 'Elenchi Puntati',
|
||||
query: 'Mi trasformi questo testo in elenchi puntati? {testo}',
|
||||
|
||||
@@ -124,18 +124,6 @@ router.post('/:userId', authenticate, async function (req, res, next) {
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, cart: null, myord: null });
|
||||
}
|
||||
|
||||
/*
|
||||
Cart.updateCartByUserId(
|
||||
userId,
|
||||
newCart,
|
||||
function (err, result) {
|
||||
if (err) return next(err)
|
||||
return res.status(200).json({ cart: result })
|
||||
})
|
||||
|
||||
*/
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err:', e);
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, cart: 0 });
|
||||
@@ -189,16 +177,16 @@ router.put('/:userId', authenticate, async function (req, res, next) {
|
||||
|
||||
try {
|
||||
|
||||
await Cart.getCartByUserId(userId, async function (err, c) {
|
||||
if (err) return next(err)
|
||||
let oldCart = new CartClass(c || {})
|
||||
try {
|
||||
const cart = await Cart.getCartByUserId(userId);
|
||||
|
||||
try {
|
||||
const p = await Product.getProductByID(productId);
|
||||
|
||||
await Product.getProductByID(productId, async function (err, p) {
|
||||
if (err) return next(err)
|
||||
let newCart = oldCart.add(p, productId, { color, size })
|
||||
|
||||
//exist cart in databse
|
||||
if (c.length > 0) {
|
||||
if (cart.length > 0) {
|
||||
await Cart.updateCartByUserId(
|
||||
userId,
|
||||
{
|
||||
@@ -221,17 +209,28 @@ router.put('/:userId', authenticate, async function (req, res, next) {
|
||||
totalPriceCalc: newCart.totalPriceCalc,
|
||||
userId: userId
|
||||
}
|
||||
await Cart.createCart(newCartobj, function (err, resultCart) {
|
||||
if (err) return next(err)
|
||||
res.status(201).json(resultCart)
|
||||
})
|
||||
try {
|
||||
const resultCart = await Cart.createCart(newCartobj);
|
||||
} catch (err) {
|
||||
return next(err)
|
||||
}
|
||||
res.status(201).json(resultCart);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const product = await Product.getProductById(productId);
|
||||
} catch (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
const product = await Product.getProductById(productId);
|
||||
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, product });
|
||||
|
||||
} catch (err) {
|
||||
return next(err)
|
||||
}
|
||||
|
||||
let oldCart = new CartClass(c || {})
|
||||
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, product });
|
||||
} catch (e) {
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||
}
|
||||
@@ -295,44 +294,42 @@ router.post('/:userId/createorderscart', authenticate, async function (req, res,
|
||||
if (!!mycart) {
|
||||
if (status === shared_consts.OrderStatus.CHECKOUT_SENT) {
|
||||
|
||||
// Porta tutto il Cart nell'Ordine e lo CREO
|
||||
return await OrdersCart.updateOrdersCartById(-1, myorderCart, async function (err, ris) {
|
||||
//if (err) return next(err)
|
||||
if (err)
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||
else {
|
||||
try {
|
||||
const ris = await OrdersCart.updateOrdersCartById(-1, myorderCart);
|
||||
// Gestisci il risultato qui
|
||||
await Order.updateStatusOrders(mycart.items, status);
|
||||
|
||||
await Order.updateStatusOrders(mycart.items, status);
|
||||
const myris = ris;
|
||||
// Cancella il Cart appena salvato in OrdersCart
|
||||
|
||||
const myris = ris;
|
||||
// Cancella il Cart appena salvato in OrdersCart
|
||||
return Cart.deleteCartByCartId(mycart._id)
|
||||
.then((ris) => {
|
||||
|
||||
return Cart.deleteCartByCartId(mycart._id)
|
||||
.then((ris) => {
|
||||
return OrdersCart.getOrdersCartByUserId(userId, idapp, numorder)
|
||||
.then(async (orders) => {
|
||||
if (!!orders) {
|
||||
|
||||
return OrdersCart.getOrdersCartByUserId(userId, idapp, numorder)
|
||||
.then(async (orders) => {
|
||||
if (!!orders) {
|
||||
await OrdersCart.updateCmd(orders[0], status, true, req, options);
|
||||
|
||||
await OrdersCart.updateCmd(orders[0], status, true, req, options);
|
||||
|
||||
// Invia la email dell'Ordine
|
||||
sendemail.sendEmail_OrderProduct(userDest.lang, idapp, orders[0], userDest)
|
||||
.then(async (ris) => {
|
||||
myorderCart = await OrdersCart.findById(idordercart).lean();
|
||||
return res.send({
|
||||
code: server_constants.RIS_CODE_OK,
|
||||
status: myris.status,
|
||||
orders: orders,
|
||||
recOrderCart: myorderCart
|
||||
});
|
||||
// Invia la email dell'Ordine
|
||||
sendemail.sendEmail_OrderProduct(userDest.lang, idapp, orders[0], userDest)
|
||||
.then(async (ris) => {
|
||||
myorderCart = await OrdersCart.findById(idordercart).lean();
|
||||
return res.send({
|
||||
code: server_constants.RIS_CODE_OK,
|
||||
status: myris.status,
|
||||
orders: orders,
|
||||
recOrderCart: myorderCart
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
} catch (err) {
|
||||
console.error("Errore durante l'aggiornamento dell'ordine:", err);
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -442,7 +439,7 @@ router.post('/:userId/gestord', authenticate, async function (req, res, next) {
|
||||
$match: {
|
||||
idGasordine: {
|
||||
$type: "objectId", // Checks if the field is of type ObjectId
|
||||
$eq: ObjectId(idGasordine) // Compares the value to a specific ObjectId
|
||||
$eq: new ObjectId(idGasordine) // Compares the value to a specific ObjectId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2274,7 +2274,7 @@ router.post('/upload_from_other_server/:dir', authenticate, (req, res) => {
|
||||
function uploadFile(req, res, version) {
|
||||
// console.log('/upload dir:' + dir);
|
||||
const dir = tools.invertescapeslash(req.params.dir);
|
||||
console.log('inverted = ', dir);
|
||||
console.log('uploadFile = ', dir);
|
||||
const idapp = req.user.idapp;
|
||||
|
||||
const form = new formidable.IncomingForm();
|
||||
@@ -2296,6 +2296,7 @@ function uploadFile(req, res, version) {
|
||||
try {
|
||||
|
||||
form.on('fileBegin', async function (name, file) {
|
||||
console.log('1) Uploading ' + file.originalFilename);
|
||||
const mydir = folder + '/' + file.newFilename;
|
||||
// tools.mkdirpath(mydir);
|
||||
file.path = mydir
|
||||
@@ -2303,7 +2304,7 @@ function uploadFile(req, res, version) {
|
||||
|
||||
form.on('file', async function (name, file) {
|
||||
try {
|
||||
console.log('1) Uploading ' + file.originalFilename);
|
||||
console.log('2) Uploading ' + file.originalFilename);
|
||||
const mydir = tools.getdirByIdApp(idapp) + dirmain +
|
||||
server_constants.DIR_UPLOAD + '/' + dir;
|
||||
|
||||
|
||||
@@ -7,16 +7,16 @@ const webpush = require('web-push');
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {authenticate} = require('../middleware/authenticate');
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
const server_constants = require('../tools/server_constants');
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const globalTables = require('../tools/globalTables');
|
||||
|
||||
router.post('/', (req, res) => {
|
||||
router.post('/', async (req, res) => {
|
||||
const payload = {
|
||||
title: req.body.title,
|
||||
message: req.body.message,
|
||||
@@ -28,60 +28,59 @@ router.post('/', (req, res) => {
|
||||
tag: req.body.tag,
|
||||
};
|
||||
|
||||
Subscription.find({}, (err, subscriptions) => {
|
||||
if (err) {
|
||||
console.error(`Error occurred while getting subscriptions`);
|
||||
res.status(500).json({
|
||||
error: 'Technical error occurred',
|
||||
});
|
||||
try {
|
||||
const subscriptions = await Subscription.find({});
|
||||
} catch (err) {
|
||||
console.error(`Error occurred while getting subscriptions`);
|
||||
res.status(500).json({
|
||||
error: 'Technical error occurred',
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
let parallelSubscriptionCalls = subscriptions.map((subscription) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const pushSubscription = {
|
||||
endpoint: subscription.endpoint,
|
||||
keys: {
|
||||
p256dh: subscription.keys.p256dh,
|
||||
auth: subscription.keys.auth,
|
||||
},
|
||||
};
|
||||
let parallelSubscriptionCalls = subscriptions.map((subscription) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const pushSubscription = {
|
||||
endpoint: subscription.endpoint,
|
||||
keys: {
|
||||
p256dh: subscription.keys.p256dh,
|
||||
auth: subscription.keys.auth,
|
||||
},
|
||||
};
|
||||
|
||||
const pushPayload = JSON.stringify(payload);
|
||||
const pushOptions = {
|
||||
vapidDetails: {
|
||||
subject: process.env.VAPI_KEY_SUBJECT,
|
||||
privateKey: process.env.PRIVATE_VAPI_KEY,
|
||||
publicKey: process.env.PUBLIC_VAPI_KEY,
|
||||
},
|
||||
TTL: payload.ttl,
|
||||
headers: {},
|
||||
};
|
||||
webpush.sendNotification(
|
||||
pushSubscription,
|
||||
pushPayload,
|
||||
pushOptions,
|
||||
).then((value) => {
|
||||
resolve({
|
||||
status: true,
|
||||
endpoint: subscription.endpoint,
|
||||
data: value,
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject({
|
||||
status: false,
|
||||
endpoint: subscription.endpoint,
|
||||
data: err,
|
||||
});
|
||||
});
|
||||
const pushPayload = JSON.stringify(payload);
|
||||
const pushOptions = {
|
||||
vapidDetails: {
|
||||
subject: process.env.VAPI_KEY_SUBJECT,
|
||||
privateKey: process.env.PRIVATE_VAPI_KEY,
|
||||
publicKey: process.env.PUBLIC_VAPI_KEY,
|
||||
},
|
||||
TTL: payload.ttl,
|
||||
headers: {},
|
||||
};
|
||||
webpush.sendNotification(
|
||||
pushSubscription,
|
||||
pushPayload,
|
||||
pushOptions,
|
||||
).then((value) => {
|
||||
resolve({
|
||||
status: true,
|
||||
endpoint: subscription.endpoint,
|
||||
data: value,
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject({
|
||||
status: false,
|
||||
endpoint: subscription.endpoint,
|
||||
data: err,
|
||||
});
|
||||
});
|
||||
q.allSettled(parallelSubscriptionCalls).then((pushResults) => {
|
||||
console.info(pushResults);
|
||||
});
|
||||
res.json({
|
||||
data: 'Push triggered',
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
q.allSettled(parallelSubscriptionCalls).then((pushResults) => {
|
||||
console.info(pushResults);
|
||||
});
|
||||
res.json({
|
||||
data: 'Push triggered',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -89,21 +88,21 @@ router.post('/', (req, res) => {
|
||||
|
||||
async function SendMsgTo(idapp, username, params) {
|
||||
|
||||
return await User.find({idapp, username}).then(async (arrusers) => {
|
||||
return await User.find({ idapp, username }).then(async (arrusers) => {
|
||||
if (arrusers !== null) {
|
||||
for (const user of arrusers) {
|
||||
await tools.sendNotificationToUser(user._id, params.title, params.content,
|
||||
params.openUrl, params.openUrl2, params.tag, params.actions, params.id).
|
||||
then(ris => {
|
||||
if (ris) {
|
||||
params.openUrl, params.openUrl2, params.tag, params.actions, params.id).
|
||||
then(ris => {
|
||||
if (ris) {
|
||||
|
||||
} else {
|
||||
// already sent the error on calling sendNotificationToUser
|
||||
}
|
||||
}).
|
||||
catch(e => {
|
||||
console.error(e.message);
|
||||
});
|
||||
} else {
|
||||
// already sent the error on calling sendNotificationToUser
|
||||
}
|
||||
}).
|
||||
catch(e => {
|
||||
console.error(e.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -119,10 +118,10 @@ router.post('/send', authenticate, async (req, res) => {
|
||||
let nummsg = 0;
|
||||
|
||||
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) &&
|
||||
!User.isFacilitatore(req.user.perm))) {
|
||||
!User.isFacilitatore(req.user.perm))) {
|
||||
// If without permissions, exit
|
||||
return res.status(404).
|
||||
send({code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: ''});
|
||||
send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
|
||||
}
|
||||
|
||||
let msgcosa = 'da Inviare';
|
||||
@@ -144,7 +143,7 @@ router.post('/send', authenticate, async (req, res) => {
|
||||
});
|
||||
} catch (e) {
|
||||
return res.send(
|
||||
{code: server_constants.RIS_CODE_ERR, msg: nummsg + ` Msg ${msgcosa} !`});
|
||||
{ code: server_constants.RIS_CODE_ERR, msg: nummsg + ` Msg ${msgcosa} !` });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -89,7 +89,7 @@ async function delNotif(res, idapp, username, id, username_call) {
|
||||
try {
|
||||
if (username === username_call) {
|
||||
|
||||
await SendNotif.findOneAndRemove({ idapp, _id: id });
|
||||
await SendNotif.findOneAndDelete({ idapp, _id: id });
|
||||
return res.send(true);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -61,29 +61,32 @@ router.post('/', authenticate, async (req, res) => {
|
||||
myitem.createDate = new Date();
|
||||
}
|
||||
|
||||
return await myitem.save((err, subscription) => {
|
||||
if (err) {
|
||||
console.error(`Error occurred while saving subscription. Err: ${err}`);
|
||||
return res.status(500).json({
|
||||
error: 'Technical error occurred',
|
||||
});
|
||||
} else {
|
||||
// Send 201 - resource created
|
||||
// res.status(201).json({ data: 'Subscription saved.' });
|
||||
try {
|
||||
const subscription = await myitem.save();
|
||||
|
||||
// console.log('New Subscription id=', subscriptionModel.userId);
|
||||
// Send 201 - resource created
|
||||
// res.status(201).json({ data: 'Subscription saved.' });
|
||||
|
||||
// console.log('req.body', req.body)
|
||||
// console.log('New Subscription id=', subscriptionModel.userId);
|
||||
|
||||
if (req.body.options !== null) {
|
||||
tools.sendBackNotif(subscription, req.body.options);
|
||||
}
|
||||
// console.log('Subscription saved... ')
|
||||
return res.send({ data: 'Subscription saved.' });
|
||||
// console.log('req.body', req.body)
|
||||
|
||||
if (req.body.options !== null) {
|
||||
tools.sendBackNotif(subscription, req.body.options);
|
||||
}
|
||||
});
|
||||
});
|
||||
// console.log('Subscription saved... ')
|
||||
return res.send({ data: 'Subscription saved.' });
|
||||
|
||||
return subscription;
|
||||
|
||||
} catch (err) {
|
||||
console.error(`Error occurred while saving subscription. Err: ${err}`);
|
||||
return res.status(500).json({
|
||||
error: 'Technical error occurred',
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
router.delete('/del', authenticate, (req, res) => {
|
||||
@@ -92,14 +95,14 @@ router.delete('/del', authenticate, (req, res) => {
|
||||
|
||||
|
||||
const browser = req.get('User-Agent');
|
||||
Subscription.findOneAndRemove(
|
||||
Subscription.findOneAndDelete(
|
||||
{ userId: req.user._id, access: req.access, browser }).then(() => {
|
||||
res.status(200).send();
|
||||
}, () => {
|
||||
res.status(400).send();
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ const _ = require('lodash');
|
||||
const { ObjectId } = require('mongodb');
|
||||
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
router.get('/', async (req, res) => {
|
||||
|
||||
const todo = {
|
||||
// category: "personal",
|
||||
@@ -52,14 +52,12 @@ router.get('/', (req, res) => {
|
||||
newrec._id = new ObjectId();
|
||||
newrec.idapp = '8';
|
||||
|
||||
newrec.save((err, rec) => {
|
||||
if (err)
|
||||
console.log('ERROR: ', err);
|
||||
if (rec) {
|
||||
console.log('SAVED? ', rec);
|
||||
}
|
||||
|
||||
});
|
||||
const rec = await newrec.save();
|
||||
if (err)
|
||||
console.log('ERROR: ', err);
|
||||
if (rec) {
|
||||
console.log('SAVED? ', rec);
|
||||
}
|
||||
|
||||
res.send({});
|
||||
|
||||
|
||||
@@ -1102,237 +1102,6 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
|
||||
await CatProd.deleteMany({ idapp });
|
||||
await SubCatProd.deleteMany({ idapp });
|
||||
} else if (mydata.dbop === 'visuStat') {
|
||||
// ris = await User.visuUtentiNonInNavi(idapp);
|
||||
//} else if (mydata.dbop === 'creaNavi') {
|
||||
// const num = await Nave.generaNave(idapp, mydata, false);
|
||||
// ris = { num };
|
||||
//} else if (mydata.dbop === 'CreaNaviPersistenti') {
|
||||
// const num = await Nave.generaNave(idapp, mydata, true);
|
||||
// ris = { num };
|
||||
/*} else if (mydata.dbop === 'delNavi') {
|
||||
await Nave.setRiga(idapp, 1);
|
||||
await Nave.setCol(idapp, 1);
|
||||
const num = await Nave.deleteOne({ idapp });
|
||||
ris = { num };
|
||||
// } else if (mydata.dbop === 'delNaviNoStarted') {
|
||||
// await Nave.setRiga(idapp, 1);
|
||||
// await Nave.setCol(idapp, 1);
|
||||
// const num = await Nave.remove({ idapp, date_start: { $gte: tools.IncDateNow(-1000 * 60 * 60 * 24 * 3) } });
|
||||
// ris = { num };
|
||||
|
||||
} else if (mydata.dbop === 'delNaviProvvisorie') {
|
||||
|
||||
ris = await Nave.delNaviProvvisorie(idapp);
|
||||
|
||||
} else if (mydata.dbop === 'visuListaNave') {
|
||||
mystr = await Nave.showListaOrd(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'pulisciNonPresenzeInNave') {
|
||||
mystr = await Nave.pulisciNonPresenzeInNave(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'checkInserimentiUtentiInNave') {
|
||||
mystr = await Nave.checkIfDevoAggiungereInNave(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'visuListaIngresso') {
|
||||
mystr = await ListaIngresso.showListaOrd(idapp, false);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'visuListaIngressoNuovi') {
|
||||
mystr = await ListaIngresso.showListaOrd(idapp, true);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'GeneraGraduatoria') {
|
||||
mystr = await ListaIngresso.GeneraGraduatoria(idapp, true);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'AggiornaIndiceGraduatoria') {
|
||||
mystr = await Graduatoria.AggiornaIndiceGraduatoria(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'visuNaviUtentiEliminati') {
|
||||
ris = await Nave.visuNaviUtentiEliminati(idapp);
|
||||
} else if (mydata.dbop === 'convSubAccount') {
|
||||
ris = await User.convSubAccount(idapp);
|
||||
} else if (mydata.dbop === 'flagUtentiNaviNonPresenti') {
|
||||
ris = await User.flagUtentiNaviNonPresenti(idapp);
|
||||
} else if (mydata.dbop === 'generaFlotte') {
|
||||
ris = await NavePersistente.generaFlotte(idapp);
|
||||
} else if (mydata.dbop === 'mettiSognoePaypal') {
|
||||
ris = await User.mettiSognoePaypal(idapp, true);
|
||||
} else if (mydata.dbop === 'mettiSognoePaypalView') {
|
||||
ris = await User.mettiSognoePaypal(idapp, false);
|
||||
} else if (mydata.dbop === 'addNavePerUtentiNaviNonPresenti') {
|
||||
ris = await User.addNavePerUtentiNaviNonPresenti(idapp);
|
||||
} else if (mydata.dbop === 'creaTessituraeConv') {
|
||||
ris = await ListaIngresso.creaTessituraeConv(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'eliminaListeIngressoNascoste') {
|
||||
ris = await ListaIngresso.eliminaListeIngressoNascoste(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'RendiVisibileIrecordNascosti') {
|
||||
ris = await ListaIngresso.RendiVisibileIrecordNascosti(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'convNaviTessinListaIngressoRec') {
|
||||
let num = 0;
|
||||
|
||||
|
||||
const arrnavitess = await Nave.find({ idapp, num_tess: { $gte: 3 } });
|
||||
|
||||
for (const recnave of arrnavitess) {
|
||||
if (recnave.num_tess === 3 || recnave.num_tess === 5 || recnave.num_tess === 7) {
|
||||
const ind_order = recnave.ind_order;
|
||||
|
||||
// Prima controlla se ho già 2 record dello stesso ind_order, allora non lo faccio:
|
||||
const arringr = await ListaIngresso.find({ idapp, ind_order });
|
||||
let dafare = true;
|
||||
if (arringr.length > 0) {
|
||||
const arringrtest = await ListaIngresso.find({ idapp, ind_order }).distinct('num_tess');
|
||||
if (arringr.length !== arringrtest.length) {
|
||||
dafare = false; // Ci sono 2 o piu record! pertanto probabilmente l'ho già fatto!
|
||||
}
|
||||
}
|
||||
if (dafare) {
|
||||
// const user = await User.findByOldOrder(idapp, ind_order);
|
||||
const user = await User.findByIndOrder(idapp, ind_order);
|
||||
|
||||
if (!!user) {
|
||||
//let note = recnave.num_tess;
|
||||
// Crea record ListaIngresso
|
||||
const newrecingr = await ListaIngresso.addUserInListaIngresso(idapp, user.username, user.username, user.lang, false, true, recnave.created, '', true);
|
||||
|
||||
const fieldsvalue = {
|
||||
ind_order: newrecingr.ind_order,
|
||||
num_tess: 1,
|
||||
};
|
||||
|
||||
// Aggiorna la nave con l'Ind_order nuovo e il num_tess a 1
|
||||
await Nave.findOneAndUpdate({ _id: recnave._id }, { $set: fieldsvalue }, { new: false });
|
||||
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const arrnavitess2 = await Nave.find({ idapp, num_tess: 2 });
|
||||
|
||||
for (const recnave of arrnavitess2) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
ris = { num };
|
||||
|
||||
} else if (mydata.dbop === 'initListaIngresso') {
|
||||
// const aaa = await User.updateMany({ idapp }, { $set: { 'profile.nationality': 'IT' } });
|
||||
|
||||
const num = await ListaIngresso.updateMany({ idapp }, { $set: { added: false } });
|
||||
|
||||
ris = { num };
|
||||
} else if (mydata.dbop === 'ImpostaATuttiPaypal') {
|
||||
const listautenti = await User.find({ idapp });
|
||||
let num = 0;
|
||||
for (let rec of listautenti) {
|
||||
if (!rec._doc.profile.paymenttypes.includes('paypal')) {
|
||||
rec._doc.profile.paymenttypes = [...rec._doc.profile.paymenttypes, 'paypal'];
|
||||
const user = await User.findOneAndUpdate({ _id: rec._id }, { $set: { 'profile.paymenttypes': rec._doc.profile.paymenttypes } });
|
||||
// await rec.save();
|
||||
num++;
|
||||
}
|
||||
// const num = await User.f({ idapp }, { $set: { 'profile: false } });
|
||||
}
|
||||
|
||||
|
||||
ris = { num };
|
||||
} else if (mydata.dbop === 'numtessUno') {
|
||||
const listanavi = await ListaIngresso.find({ idapp });
|
||||
let num = 0;
|
||||
for (let rec of listanavi) {
|
||||
if (!rec._doc.num_tess) {
|
||||
rec._doc.num_tess = 1;
|
||||
const risu = await ListaIngresso.findOneAndUpdate({ _id: rec._id }, { $set: { num_tess: rec._doc.num_tess } }, { new: false });
|
||||
// await rec.save();
|
||||
if (!!risu)
|
||||
num++;
|
||||
}
|
||||
// const num = await User.f({ idapp }, { $set: { 'profile: false } });
|
||||
}
|
||||
|
||||
|
||||
ris = { num };
|
||||
|
||||
} else if (mydata.dbop === 'Corregginumtess') {
|
||||
const listanavi = await Nave.find({ idapp });
|
||||
let num = 0;
|
||||
for (let rec of listanavi) {
|
||||
const myarrrec = await Nave.find({ idapp, ind_order: rec.ind_order }).sort({ riga: 1, col: 1 });
|
||||
let indextess = 1;
|
||||
for (let ind = 0; ind < myarrrec.length; ind++) {
|
||||
if (myarrrec[ind].num_tess !== indextess && myarrrec[ind].num_tess === 1) {
|
||||
myarrrec[ind].num_tess = indextess;
|
||||
const risu = await Nave.findOneAndUpdate({ _id: myarrrec[ind]._id }, { $set: { num_tess: myarrrec[ind].num_tess } }, { new: false });
|
||||
num++;
|
||||
}
|
||||
indextess++;
|
||||
}
|
||||
}
|
||||
|
||||
ris = { num };
|
||||
*/
|
||||
/*
|
||||
}
|
||||
|
||||
else if (mydata.dbop === 'CreaNaviPersistenti') {
|
||||
const listanavi = await Nave.find({ idapp }).sort({riga: 1, col: 1});
|
||||
|
||||
let params = {
|
||||
idapp
|
||||
};
|
||||
|
||||
let num = 0;
|
||||
for (let rec of listanavi) {
|
||||
let mypos = {
|
||||
idapp,
|
||||
riga: rec.riga,
|
||||
col: rec.col,
|
||||
numup: 3
|
||||
};
|
||||
tools.getRigaColByPosUp(mypos);
|
||||
let persistente = await NavePersistente.findByRigaCol(idapp, mypos.riga, mypos.col, 0);
|
||||
if (!persistente) {
|
||||
|
||||
params.date_start = rec.date_start;
|
||||
params.date_gift_chat_open = rec.date_gift_chat_open;
|
||||
params.riga = mypos.riga;
|
||||
params.col = mypos.col;
|
||||
if (rec.riga > 3) {
|
||||
params.riga1don = rec.riga;
|
||||
params.col1don = rec.col;
|
||||
} else {
|
||||
params.riga1don = rec.riga;
|
||||
params.col1don = rec.col;
|
||||
}
|
||||
if (params.riga > 0) {
|
||||
await NavePersistente.addRecordNavePersistenteByParams(params);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ris = { num }; */
|
||||
/*} else if (mydata.dbop === 'CorreggiDataGiftChat') {
|
||||
const listanavi = await NavePersistente.find({ idapp });
|
||||
let num = 0;
|
||||
for (let rec of listanavi) {
|
||||
const fieldsvalue = {
|
||||
date_gift_chat_open: tools.AddDate(rec.date_start, -7)
|
||||
};
|
||||
const risu = await NavePersistente.findOneAndUpdate({ _id: rec._id }, { $set: fieldsvalue }, { new: false });
|
||||
if (!!risu) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
ris = { num };
|
||||
*/
|
||||
} else if (mydata.dbop === 'creaUtentiTest') {
|
||||
|
||||
let num = 0;
|
||||
@@ -1655,8 +1424,8 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
const { City } = require('../models/city');
|
||||
const { Province } = require('../models/province');
|
||||
|
||||
await City.remove({});
|
||||
await Province.remove({});
|
||||
await City.deleteMany({});
|
||||
await Province.deleteMany({});
|
||||
|
||||
} else if (mydata.dbop === 'ConvTablesFromIntToString') {
|
||||
|
||||
@@ -1840,19 +1609,16 @@ async function ConvertiDaIntAStr(mytable) {
|
||||
myrec._doc.date_created = myrec._doc.date_updated;
|
||||
myrec._doc._id = idint + '';
|
||||
|
||||
let ris = await myrec.save((async function (err, doc) {
|
||||
if (doc) {
|
||||
ind++;
|
||||
//await mytable.findOneAndRemove({ _id: parseInt(doc._id, 10) });
|
||||
console.log('++Add (', ind, ')', doc._id);
|
||||
} else {
|
||||
const myid = parseInt(err.keyValue._id, 10) + 0;
|
||||
const canc = await mytable.findOneAndRemove({ _id: myid });
|
||||
if (canc)
|
||||
console.log('err', err.message, 'canc', canc._doc._id);
|
||||
}
|
||||
|
||||
}));
|
||||
try {
|
||||
const doc = await myrec.save();
|
||||
ind++;
|
||||
console.log('++Add (', ind, ')', doc._id);
|
||||
} catch (err) {
|
||||
const myid = parseInt(err.keyValue._id, 10) + 0;
|
||||
const canc = await mytable.findOneAndDelete({ _id: myid });
|
||||
if (canc)
|
||||
console.log('err', err.message, 'canc', canc._doc._id);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -955,7 +955,7 @@ module.exports = {
|
||||
const updateml = await User.findOneAndUpdate({
|
||||
idapp,
|
||||
email: user.email,
|
||||
}, { $set: { lastid_newstosent: ObjectId(id_newstosent) } }, { new: false });
|
||||
}, { $set: { lastid_newstosent: new ObjectId(id_newstosent) } }, { new: false });
|
||||
|
||||
//Delay for send email...
|
||||
await tools.snooze(secpause);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user