- Cataloghi

- Import ed Export Pagine
- ObjectID sostituita con ObjectId
This commit is contained in:
Surya Paolo
2024-12-17 17:55:47 +01:00
parent 14b3e18986
commit 300bab2125
91 changed files with 404 additions and 272 deletions

View File

@@ -9,7 +9,7 @@ const Hours = require('../models/hours');
//const { ListaIngresso } = require('../models/listaingresso');
//const { Graduatoria } = require('../models/graduatoria');
// const { ExtraList } = require('../models/extralist');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const sendemail = require('../sendemail');
@@ -1338,7 +1338,7 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
for (let ind = 0; ind < 100; ind++) {
let myuser = new User();
myuser._id = new ObjectID();
myuser._id = new ObjectId();
myuser.index = last + ind + 1;
myuser.idapp = idapp;
myuser.password = '$2a$12$DEaX1h5saTUVC43f7kubyOAlah1xHDgqQTfSIux0.RFDT9WGbyCaG';
@@ -1552,23 +1552,34 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
} else if (mydata.dbop === 'dropProducts') {
await Product.collection.drop();
ris = await ProductInfo.collection.drop();
if (idapp) {
const deleteProducts = await Product.deleteMany({ idapp });
console.log(`Cancellati ${deleteProducts.deletedCount} record dalla collezione Product.`);
// Cancellazione dei record nella collezione ProductInfo
const deleteProductInfo = await ProductInfo.deleteMany({ idapp });
console.log(`Cancellati ${deleteProductInfo.deletedCount} record dalla collezione ProductInfo.`);
}
ris = !!deleteProductInfo;
} else if (mydata.dbop === 'dropCatProd') {
await CatProd.collection.drop();
const deleteCatProd = await CatProd.deleteMany({ idapp });
} else if (mydata.dbop === 'dropSubCatProd') {
await SubCatProd.collection.drop();
const deleteSubCatProd = await SubCatProd.deleteMany({ idapp });
} else if (mydata.dbop === 'dropAllOrders') {
try {
ris = Order.collection.drop();
ris = OrdersCart.collection.drop();
ris = Cart.collection.drop();
const deleteOrder = await Order.deleteMany({ idapp });
const deleteOrdersCart = await OrdersCart.deleteMany({ idapp });
const deleteCart = await Cart.deleteMany({ idapp });
ris = deleteCart;
} catch (e) {
console.error('Err:', e);
}
@@ -1601,7 +1612,7 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
} else if (mydata.dbop === 'dropAllCarts') {
ris = Cart.collection.drop();
ris = await Cart.deleteMany({ idapp });
} else if (mydata.dbop === 'RewriteCitiesTable') {