- 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

@@ -10,7 +10,7 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
@@ -24,7 +24,7 @@ const AccountSchema = new Schema({
_id: {
type: String,
default: function () {
return new ObjectID().toString();
return new ObjectId().toString();
},
},
idapp: {
@@ -105,7 +105,7 @@ AccountSchema.statics.findAllIdApp = async function (idapp) {
AccountSchema.pre('save', async function (next) {
if (this.isNew) {
this._id = new ObjectID().toString();
this._id = new ObjectId().toString();
}
next();
@@ -304,7 +304,7 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
if (!myaccount && createifnotexist) {
myaccount = new Account({
_id: new ObjectID().toString(),
_id: new ObjectId().toString(),
idapp,
username: (!groupname && !contocom) ? username : '',
groupname,

View File

@@ -6,7 +6,7 @@ mongoose.level = "";
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
const {ObjectId} = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ mongoose.level = "";
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
const {ObjectId} = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -11,7 +11,7 @@ const { MyGroup } = require('./mygroup');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -24,7 +24,7 @@ const AttivitaSchema = new Schema(
_id: {
type: String,
default: function () {
return new ObjectID().toString();
return new ObjectId().toString();
},
},
idapp: {

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";

View File

@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -5,7 +5,7 @@ mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const { Movement } = require('../models/movement');
const { Account } = require('../models/account');
@@ -26,7 +26,7 @@ const CircuitSchema = new Schema({
_id: {
type: String,
default: function () {
return new ObjectID().toString();
return new ObjectId().toString();
},
},
idapp: {
@@ -233,7 +233,7 @@ const CircuitSchema = new Schema({
CircuitSchema.pre('save', async function (next) {
if (this.isNew) {
this._id = new ObjectID().toString();
this._id = new ObjectId().toString();
this.date_created = new Date();
}

View File

@@ -8,7 +8,7 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const fs = require('fs-extra');

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ const _ = require('lodash');
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const { Settings } = require('./settings');
@@ -226,7 +226,7 @@ function addRecGraduatoria(idapp, ingr, index) {
try {
let rec = new Graduatoria({
_id: new ObjectID(),
_id: new ObjectId(),
idapp,
idListaIngresso: ingr._id,
ind_order: ingr.ind_order,

View File

@@ -12,9 +12,7 @@ mongoose.plugin(schema => {
schema.options.usePushEach = true
});
var ObjectId = mongoose.Types.ObjectId;
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const HoursSchema = new Schema({
idapp: {

View File

@@ -5,7 +5,7 @@ const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";

View File

@@ -5,7 +5,7 @@ const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";

View File

@@ -5,7 +5,7 @@ const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";

View File

@@ -5,7 +5,7 @@ const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";

View File

@@ -6,7 +6,7 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
const {ObjectId} = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const { Account } = require('../models/account');
// Resolving error Unknown modifier: $pushAll
@@ -18,7 +18,7 @@ const MovementSchema = new Schema({
_id: {
type: String,
default: function () {
return new ObjectID().toString();
return new ObjectId().toString();
},
},
idapp: {

View File

@@ -6,7 +6,7 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
const { Reaction } = require('./reaction');
@@ -24,7 +24,7 @@ const MyBachecaSchema = new Schema({
_id: {
type: String,
default: function () {
return new ObjectID().toString();
return new ObjectId().toString();
},
},
idapp: {

View File

@@ -2,7 +2,7 @@ const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');
const { ObjectID, ObjectId } = require('mongodb');
const { ObjectId } = require('mongodb');
const { MySchedaSchema, IDimensioni, IImg, IText, IAreaDiStampa } = require('../models/myscheda');
@@ -246,7 +246,7 @@ const MyElemSchema = new Schema({
MyElemSchema.pre('save', async function (next) {
if (this.isNew) {
this._id = new ObjectID();
this._id = new ObjectId();
}
next();
@@ -280,16 +280,19 @@ MyElemSchema.statics.SetIdPageInsteadThePah = async function (idapp) {
// Aggiorna MyElem utilizzando la mappa
for (const [path, id] of Object.entries(pathToIdMap)) {
await MyElem.updateMany(
{ path: path }, // Condizione per aggiornare dove il path corrisponde
{
$set: {
idPage: id,
oldpath: path,
},
$unset: { path: "" } // Rimuove il campo path
} // Imposta IdPage all'ID del documento corrispondente
);
if (path) {
await MyElem.updateMany(
{ idapp },
{ path: path }, // Condizione per aggiornare dove il path corrisponde
{
$set: {
idPage: id,
oldpath: path,
},
$unset: { path: "" } // Rimuove il campo path
} // Imposta IdPage all'ID del documento corrispondente
);
}
}
if (false) {
@@ -319,6 +322,21 @@ MyElemSchema.statics.SetIdPageInsteadThePah = async function (idapp) {
}
}
const pathToIdMap2 = {};
pages.forEach(page => {
pathToIdMap2[page.path] = page._id.toString(); // Mappa il path all'ID del documento MyPage
});
for (const [oldpath, id] of Object.entries(pathToIdMap2)) {
await MyElem.updateMany(
{ idapp },
{ oldpath: oldpath }, // Condizione per aggiornare dove il path corrisponde
{
$set: { idPage: id }
} // Imposta IdPage all'ID del documento corrispondente
);
}
console.log('Aggiornamenti effettuati con successo.');
return 'Aggiornamenti effettuati con successo.';
@@ -340,7 +358,9 @@ MyElemSchema.statics.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await MyElem.find(myfind).sort({ order: 1 });
const arrrec = await MyElem.find(myfind).sort({ order: 1 });
return arrrec;
};
MyElemSchema.statics.findallSchedeTemplate = async function (idapp) {

View File

@@ -6,7 +6,7 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
const {ObjectId} = require('mongodb');
const {Settings} = require('./settings');

View File

@@ -11,7 +11,7 @@ const { MyGroup } = require('./mygroup');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -8,7 +8,7 @@ const shared_consts = require('../tools/shared_nodejs');
mongoose.Promise = global.Promise;
mongoose.level = 'F';
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -19,7 +19,7 @@ const MyGroupSchema = new Schema({
_id: {
type: String,
default: function () {
return new ObjectID().toString();
return new ObjectId().toString();
},
},
idapp: {

View File

@@ -10,7 +10,7 @@ const { Reaction } = require('./reaction');
const { MyGroup } = require('./mygroup');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -2,7 +2,7 @@ const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');
const { ObjectID, ObjectId } = require('mongodb');
const { ObjectId } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";

View File

@@ -11,7 +11,7 @@ const { MyGroup } = require('./mygroup');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -24,7 +24,7 @@ const MySkillSchema = new Schema(
_id: {
type: String,
default: function () {
return new ObjectID().toString();
return new ObjectId().toString();
},
},
idapp: {

View File

@@ -4,7 +4,7 @@ const Schema = mongoose.Schema;
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";
@@ -377,7 +377,7 @@ module.exports.updateTotals = function (order) {
module.exports.getTotalOrderById = async function (id) {
const query = [
{ $match: { _id: ObjectID(id) } },
{ $match: { _id: ObjectId(id) } },
{
$lookup: {
from: 'products',
@@ -660,7 +660,7 @@ module.exports.GeneraCSVOrdineProdotti = async function () {
const myidGasordine = '65c2a8cc379ee4f57e865ee7';
const myquery = [
{ $match: { idGasordine: ObjectID(myidGasordine) } },
{ $match: { idGasordine: ObjectId(myidGasordine) } },
{
$lookup: {
from: 'products',

View File

@@ -20,7 +20,7 @@ const Cart = require('../models/cart');
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const OrdersCartSchema = new Schema({
idapp: {
@@ -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: ObjectId(id) };
const arrris = await OrdersCart.getOrdersCartByQuery(query);
let myrec = arrris && arrris.length > 0 ? arrris[0] : null;

View File

@@ -13,7 +13,7 @@ const Scontistica = require('../models/scontistica');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";
@@ -212,6 +212,15 @@ const productSchema = new Schema({
gas_name: {
type: String,
},
date_created: {
type: Date,
default: Date.now
},
date_updated: {
type: Date,
},
});
var Product = module.exports = mongoose.model('Product', productSchema);
@@ -992,7 +1001,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: ObjectId(prod._id) }, { $set: objtoset })
const objDelete = {
cat_name: 1,
@@ -1005,7 +1014,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: ObjectId(prod._id) }, { $unset: objDelete })
if (ris && ris.nModified > 0) {
console.log('Modificato: ', objtoset.name);

View File

@@ -123,20 +123,25 @@ const productInfoSchema = new Schema({
collezione: {
type: String,
},
date_publishing: {
date_pub: {
type: Date,
},
date_publishing_ts: {
date_pub_ts: {
type: Number,
},
productTypes: [{
type: Number,
}],
totaleVenduti: Number,
venditeLastM: Number,
venditeLast6M: Number,
venditeLastY: Number,
venditeLast2Y: Number,
date_updated: {
type: Date,
},
totVen: Number,
vLastM: Number,
vLast6M: Number,
vLastY: Number,
vLast2Y: Number,
dataUltimoOrdine: Date,
rank3M: Number,
rank6M: Number,
@@ -152,7 +157,12 @@ const productInfoSchema = new Schema({
var productInfo = module.exports = mongoose.model('ProductInfo', productInfoSchema);
module.exports.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string }]
return [
{ field: 'name', type: tools.FieldType.string },
{ field: 'code', type: tools.FieldType.string },
{ field: 'sku', type: tools.FieldType.string },
{ field: 'codice_EAN', type: tools.FieldType.string },
]
};
module.exports.executeQueryTable = function (idapp, params) {

View File

@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
mongoose.Promise = global.Promise;
mongoose.level = "F";
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -8,7 +8,7 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');

View File

@@ -8,7 +8,7 @@ const tools = require('../tools/general');
// const CatAI = require('./catai');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -10,7 +10,7 @@ const shared_consts = require('../tools/shared_nodejs');
mongoose.Promise = global.Promise;
mongoose.level = "F";
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -4,7 +4,7 @@ const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ mongoose.level = 'F';
const i18n = require('i18n');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
const server_constants = require('../tools/server_constants');
@@ -894,7 +894,7 @@ sendNotifSchema.statics.updateStatusAndDescr = async function (myrecnotif, onlys
}
// myrecnotif._id = new ObjectID();
// myrecnotif._id = new ObjectId();
if (newstatus > 0) {
myrecnotif.status = newstatus;
}

View File

@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";
@@ -129,7 +129,7 @@ SettingsSchema.statics.setKeyNum = async function (idapp, key, value) {
let myrec = await Settings.findOne({ idapp, key });
if (!myrec) {
myrec = new Settings({ key });
myrec._id = new ObjectID();
myrec._id = new ObjectId();
myrec.idapp = idapp;
myrec.type = tools.FieldType.number;
myrec.value_num = value;
@@ -149,7 +149,7 @@ SettingsSchema.statics.setBool = async function (idapp, key, valbool) {
let myrec = await Settings.findOne({ idapp, key });
if (!myrec) {
myrec = new Settings({ key });
myrec._id = new ObjectID();
myrec._id = new ObjectId();
myrec.idapp = idapp;
myrec.type = tools.FieldType.boolean;
myrec.value_bool = valbool;

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
mongoose.set('debug', false);
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const _ = require('lodash');
@@ -412,7 +412,7 @@ module.exports.createFirstUserAdmin = async function () {
const utenteadmin = { idapp: '13', username: telegrambot.ADMIN_USER_SERVER };
const newuser = new User(utenteadmin);
newuser._id = new ObjectID();
newuser._id = new ObjectId();
newuser.idapp = mysite.idapp;
newuser.profile.mygroups = [];
newuser.profile.mycircuits = [];

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -13,9 +13,7 @@ const { MyGroup } = require('../models/mygroup');
const { Settings } = require('../models/settings');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
var ObjectId = mongoose.Types.ObjectId;
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll

View File

@@ -4,7 +4,7 @@ const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -6,7 +6,7 @@ mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -2,7 +2,7 @@ var mongoose = require('mongoose').set('debug', false)
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const tools = require('../tools/general');
var { Project } = require('./project');
@@ -108,7 +108,7 @@ TodoSchema.statics.findByUserIdAndIdParent = function (userId, category, phase =
var Todo = this;
let tofind = {
category: ObjectID(category),
category: ObjectId(category),
$or:
[{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]

View File

@@ -24,7 +24,7 @@ const { Circuit } = require('../models/circuit');
const { Account } = require('../models/account');
const { Movement } = require('../models/movement');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const i18n = require('i18n');
@@ -6199,7 +6199,7 @@ UserSchema.statics.addNewSite = async function (idappPass, body) {
// Nessun Sito Installato e Nessun Utente installato !
let myuser = new User();
myuser._id = new ObjectID();
myuser._id = new ObjectId();
myuser.idapp = idapp;
myuser.email = body.email;
myuser.username = body.username;