- 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

@@ -32,7 +32,7 @@ GCM_API_KEY=""
PROD=0
PROJECT_DESCR_MAIN='__PROJECTS'
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
TOKEN_LIFE=1m
TOKEN_LIFE=2h
REFRESH_TOKEN_LIFE=14d
FTPSERVER_HOST=139.162.166.31
FTPSERVER_PORT=21

View File

@@ -79,7 +79,7 @@ var mongoose = require('mongoose').set('debug', false);
mongoose.set('debug', false);
const { CfgServer } = require('./models/cfgserver');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const populate = require('./populate/populate');
const { Circuit } = require('./models/circuit');
@@ -453,7 +453,7 @@ async function mystart() {
function populateDBadmin() {
const cfgserv = [
{
_id: new ObjectID(),
_id: new ObjectId(),
idapp: '9',
chiave: 'vers',
userId: 'ALL',

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,7 +280,9 @@ MyElemSchema.statics.SetIdPageInsteadThePah = async function (idapp) {
// Aggiorna MyElem utilizzando la mappa
for (const [path, id] of Object.entries(pathToIdMap)) {
if (path) {
await MyElem.updateMany(
{ idapp },
{ path: path }, // Condizione per aggiornare dove il path corrisponde
{
$set: {
@@ -291,6 +293,7 @@ MyElemSchema.statics.SetIdPageInsteadThePah = async function (idapp) {
} // Imposta IdPage all'ID del documento corrispondente
);
}
}
if (false) {
// Utilizza una mappa per accoppiare i path con i loro Id
@@ -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;

View File

@@ -1,7 +1,7 @@
const shared_consts = require('../tools/shared_nodejs');
const cartModel = require('../models/cart')
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const Gasordine = require('../models/gasordine');

View File

@@ -1,92 +1,92 @@
const {ObjectID} = require('mongodb');
const {ObjectId} = require('mongodb');
module.exports = {
list: [
{
"_id" : ObjectID("615a353c002c8298f4495be7"),
"_id" : ObjectId("615a353c002c8298f4495be7"),
"idapp" : "1",
"label" : "Dono",
"__v" : 0
},
{
"_id" : ObjectID("61bc466567de9a1f54b25494"),
"_id" : ObjectId("61bc466567de9a1f54b25494"),
"idapp" : "1",
"label" : "Offerta Libera",
"__v" : 0
},
{
"_id" : ObjectID("61bc454867de9a1f54b25462"),
"_id" : ObjectId("61bc454867de9a1f54b25462"),
"idapp" : "1",
"label" : "Baratto (scambio Beni o Servizi)",
"__v" : 0
},
{
"_id" : ObjectID("61bc482667de9a1f54b2549c"),
"_id" : ObjectId("61bc482667de9a1f54b2549c"),
"idapp" : "1",
"label" : "Scambio Lavoro",
"__v" : 0
},
{
"_id" : ObjectID("61bc482667de9a1f54b2649c"),
"_id" : ObjectId("61bc482667de9a1f54b2649c"),
"idapp" : "1",
"label" : "Monete Alternative",
"__v" : 0
},
{
"_id" : ObjectID("61bc482667de9a1f54b3549e"),
"_id" : ObjectId("61bc482667de9a1f54b3549e"),
"idapp" : "1",
"label" : "Euro",
"__v" : 0
},
{
"_id" : ObjectID("615a353c002c8298f4495bf7"),
"_id" : ObjectId("615a353c002c8298f4495bf7"),
"idapp" : "12",
"label" : "Dono",
"__v" : 0
},
{
"_id" : ObjectID("61bc466567de9a1f54b254f4"),
"_id" : ObjectId("61bc466567de9a1f54b254f4"),
"idapp" : "12",
"label" : "Offerta Libera",
"__v" : 0
},
{
"_id" : ObjectID("61bc454867de9a1f54b254f2"),
"_id" : ObjectId("61bc454867de9a1f54b254f2"),
"idapp" : "12",
"label" : "Baratto",
"__v" : 0
},
{
"_id" : ObjectID("61bc482667de9a1f54b25412"),
"_id" : ObjectId("61bc482667de9a1f54b25412"),
"idapp" : "12",
"label" : "Scambio Lavoro",
"__v" : 0
},
{
"_id" : ObjectID("61bc482667de9a1f64b254ab"),
"_id" : ObjectId("61bc482667de9a1f64b254ab"),
"idapp" : "12",
"label" : "Monete Alternative",
"__v" : 0
},
{
"_id" : ObjectID("61bc482667de9a1f64b254fb"),
"_id" : ObjectId("61bc482667de9a1f64b254fb"),
"idapp" : "12",
"label" : "Euro",
"__v" : 0
},
{
"_id" : ObjectID("5dbc6b0801234f629f75e98d"),
"_id" : ObjectId("5dbc6b0801234f629f75e98d"),
"idapp" : "2",
"__v" : 0,
"label" : "Offerta Libera"
},
/* 2 */
{
"_id" : ObjectID("5dbc6b1001234f629f75e98e"),
"_id" : ObjectId("5dbc6b1001234f629f75e98e"),
"idapp" : "2",
"__v" : 0,
"label" : "Ingresso Gratuito"
@@ -94,7 +94,7 @@ module.exports = {
/* 3 */
{
"_id" : ObjectID("5dbc6b1801234f629f75e98f"),
"_id" : ObjectId("5dbc6b1801234f629f75e98f"),
"idapp" : "2",
"__v" : 0,
"label" : "Contributo",
@@ -103,13 +103,13 @@ module.exports = {
/* 4 */
{
"_id" : ObjectID("5dbc6b3001234f629f75e990"),
"_id" : ObjectId("5dbc6b3001234f629f75e990"),
"idapp" : "2",
"__v" : 0
},
{
"_id" : ObjectID("602c315137d9f0738ded312f"),
"_id" : ObjectId("602c315137d9f0738ded312f"),
"idapp" : "10",
"__v" : 0,
"label" : "Contributo",
@@ -118,7 +118,7 @@ module.exports = {
/* 7 */
{
"_id" : ObjectID("602c316037d9f0738ded3132"),
"_id" : ObjectId("602c316037d9f0738ded3132"),
"idapp" : "10",
"__v" : 0,
"label" : "Gratuito"
@@ -126,61 +126,61 @@ module.exports = {
/* 8 */
{
"_id" : ObjectID("60514b3f733ce468d09366f2"),
"_id" : ObjectId("60514b3f733ce468d09366f2"),
"idapp" : "10",
"__v" : 0,
"label" : "Evento ONLINE Gratuito"
},
{
"_id" : ObjectID("515a353c002c8298f4495bf7"),
"_id" : ObjectId("515a353c002c8298f4495bf7"),
"idapp" : "13",
"label" : "Dono",
"__v" : 0
},
{
"_id" : ObjectID("51bc466567de9a1f54b254f4"),
"_id" : ObjectId("51bc466567de9a1f54b254f4"),
"idapp" : "13",
"label" : "Offerta Libera",
"__v" : 0
},
{
"_id" : ObjectID("51bc454867de9a1f54b254f2"),
"_id" : ObjectId("51bc454867de9a1f54b254f2"),
"idapp" : "13",
"label" : "Baratto",
"__v" : 0
},
{
"_id" : ObjectID("51bc482667de9a1f54b25412"),
"_id" : ObjectId("51bc482667de9a1f54b25412"),
"idapp" : "13",
"label" : "Scambio Lavoro",
"__v" : 0
},
{
"_id" : ObjectID("51bc482667de9a1f64b254ab"),
"_id" : ObjectId("51bc482667de9a1f64b254ab"),
"idapp" : "13",
"label" : "Monete Alternative",
"__v" : 0
},
{
"_id" : ObjectID("51bc482667de9a1f64b254ac"),
"_id" : ObjectId("51bc482667de9a1f64b254ac"),
"idapp" : "13",
"label" : "RIS",
"__v" : 0
},
{
"_id" : ObjectID("51bc482667de9a1f64b254fb"),
"_id" : ObjectId("51bc482667de9a1f64b254fb"),
"idapp" : "13",
"label" : "Euro",
"__v" : 0
},
{
"_id" : ObjectID("51bc482667de9a1f64b254ff"),
"_id" : ObjectId("51bc482667de9a1f64b254ff"),
"idapp" : "13",
"label" : "Bitcoin",
"__v" : 0
},
{
"_id" : ObjectID("51bc482667de9a1f64b255ff"),
"_id" : ObjectId("51bc482667de9a1f64b255ff"),
"idapp" : "13",
"label" : "Banca del Tempo",
"__v" : 0

View File

@@ -1,9 +1,9 @@
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
module.exports = {
list: [
{
_id: ObjectID("115a353c002c298f44900010"),
_id: ObjectId("115a353c002c298f44900010"),
idapp: 18,
ask: [
{ descr: 'Scegli quanti punti', value: 'numpunti' },
@@ -13,7 +13,7 @@ module.exports = {
output_type: 'ELENCO',
},
{
_id: ObjectID("115a353c002c298f44900020"),
_id: 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: ObjectId("115a353c002c829f44900030"),
idapp: 18,
ask: [],
descr: 'Estrai le cose importanti dell\'articolo',
@@ -31,7 +31,7 @@ module.exports = {
output_type: '',
},
{
_id: ObjectID("115a353c002c8298f4900040"),
_id: ObjectId("115a353c002c8298f4900040"),
idapp: 18,
ask: [],
descr: 'Dammi degli Emoji',
@@ -40,7 +40,7 @@ module.exports = {
output_type: '',
},
{
_id: ObjectID("115a353c002c298f44900050"),
_id: ObjectId("115a353c002c298f44900050"),
idapp: 18,
ask: [
{ descr: 'Scegli quanti Punti', value: 'numpunti' },
@@ -50,13 +50,13 @@ module.exports = {
output_type: 'ELENCO',
},
{
_id: ObjectID("115a353c002c898f44900060"),
_id: ObjectId("115a353c002c898f44900060"),
idapp: 18,
descr: 'Scaletta punti',
query: 'Mi fai una scaletta di punti che potrei affrontare durante il webinar.',
},
{
_id: ObjectID("115a353c002c829f44900070"),
_id: ObjectId("115a353c002c829f44900070"),
idapp: 18,
descr: 'Elenchi Puntati',
query: 'Mi trasformi questo testo in elenchi puntati? {testo}',

View File

@@ -15,7 +15,7 @@ const { Account } = require('../models/account');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
async function getCircuitRecAdminsInfo(idapp, data) {

View File

@@ -634,7 +634,7 @@ router.post('/import', authenticate, async (req, res) => {
let imported = 0;
let errors = 0;
const ripopola = false;
const ripopola = true;
dataObjects = null;
@@ -650,10 +650,12 @@ router.post('/import', authenticate, async (req, res) => {
if (myarr && ripopola) {
console.log('*** INIZIO IMPORT RIPOPOLAMENTO ... ', myarr.length);
// Cancella la collection ImportaMacros
await ImportaDescr.deleteMany({ idapp });
// Aggiungi i record su ImportaMacros
// Aggiungi i record su ImportaDescr
for (const recinv of myarr) {
let isnuovo = false
let setta = false
@@ -669,12 +671,15 @@ router.post('/import', authenticate, async (req, res) => {
let queryprod = { idapp, code: recmacro._id };
try {
let risrec = await ImportaDescr.findOneAndUpdate(queryprod, { $set: recmacro }, { new: true, upsert: true, strict: false });
// non inserisce nuovi record, se non lo trova ! perché sono troppi !
let risrec = await ImportaDescr.findOneAndUpdate(queryprod,
{ $set: recmacro }, { new: true, upsert: true, strict: false }
);
if (risrec) {
imported++;
// if (imported > 1000)
// break;
if (imported % 10 === 0)
if (imported % 50 === 0)
console.log('importato ', imported, 'su ', myarr.length);
}
@@ -717,23 +722,23 @@ router.post('/import', authenticate, async (req, res) => {
// IMPOSTA I VALORI SOLO SE NON ESISTONO ! ALTRIMENTI LASCIA QUELLI GIA' IMPORTATI (O MODIFICATI)
if (getvalueByJsonText(product.url)) {
if (!myproductInfo.link_macro)
if ((myproductInfo && !myproductInfo.link_macro) || !myproductInfo)
productInfo.link_macro = getvalueByJsonText(product.url);
}
if (getvalueByJsonText(product.descrizione)) {
if (!myproductInfo.descrizione_completa_macro)
if ((myproductInfo && !myproductInfo.descrizione_breve_macro) || !myproductInfo)
productInfo.descrizione_breve_macro = getvalueByJsonText(product.descrizione);
}
if (getvalueByJsonText(product.descrizione_completa)) {
if (!myproductInfo.descrizione_completa_macro)
if ((myproductInfo && !myproductInfo.descrizione_completa_macro) || !myproductInfo)
productInfo.descrizione_completa_macro = getvalueByJsonText(product.descrizione_completa)
}
if (getvalueByJsonText(product.sottotitolo)) {
if (!myproductInfo.sottotitolo)
if ((myproductInfo && !myproductInfo.sottotitolo) || !myproductInfo)
productInfo.sottotitolo = getvalueByJsonText(product.sottotitolo);
}
if (getvalueByJsonText(product.titolo)) {
if (!myproductInfo.name)
if ((myproductInfo && !myproductInfo.name) || !myproductInfo)
productInfo.name = getvalueByJsonText(product.titolo);
}
@@ -756,7 +761,7 @@ router.post('/import', authenticate, async (req, res) => {
let risrecInfo = await ProductInfo.findOneAndUpdate({ code: productInfo.code }, { $set: productInfo }, { new: true, upsert: true });
indprod++;
if (indprod % 10 === 0)
if (indprod % 50 === 0)
console.log(indprod + '/' + numprod);
}
}
@@ -783,14 +788,14 @@ router.post('/import', authenticate, async (req, res) => {
if (dataObjects && dataObjects[0]) {
// Cancella la collection ImportaMacros
// Cancella la collection ImportaIsbn
await ImportaIsbn.deleteMany({ idapp });
const numtot = dataObjects[0].length
console.log('Numero di RECORD da Importare = ', numtot);
// Aggiungi i record su ImportaMacros
// Aggiungi i record su ImportaIsbn
for (const recinv of dataObjects[0]) {
let recmacro = recinv;
@@ -809,7 +814,7 @@ router.post('/import', authenticate, async (req, res) => {
let risrec = await ImportaIsbn.findOneAndUpdate(queryprod, { $set: recmacro }, { new: true, upsert: true, strict: false });
if (risrec) {
imported++;
if ((imported % 10) === 0)
if ((imported % 50) === 0)
console.log('Importati dir TEMPORANEA ... ', imported + '/' + numtot);
}
@@ -836,11 +841,11 @@ router.post('/import', authenticate, async (req, res) => {
// Rimuove prima tutti i valori precedenti
let risupdate = await ProductInfo.updateMany({ idapp }, {
$set: {
totaleVenduti: 0,
venditeLastM: 0,
venditeLast6M: 0,
venditeLastY: 0,
venditeLast2Y: 0,
totVen: 0,
vLastM: 0,
vLast6M: 0,
vLastY: 0,
vLast2Y: 0,
rank3M: 0,
rank6M: 0,
rank1Y: 0,
@@ -876,20 +881,20 @@ router.post('/import', authenticate, async (req, res) => {
// id_wp: product._id,
// name: product.title,
totaleVenduti: product.totaleVenduti || 0,
venditeLastM: product.venditeLastM || 0,
venditeLast6M: product.venditeLast6M || 0,
venditeLastY: product.venditeLastY || 0,
venditeLast2Y: product.venditeLast2Y || 0,
totVen: product.totVen || 0,
vLastM: product.vLastM || 0,
vLast6M: product.vLast6M || 0,
vLastY: product.vLastY || 0,
vLast2Y: product.vLast2Y || 0,
rank3M: product.rank3M || 0,
rank6M: product.rank6M || 0,
rank1Y: product.rank1Y || 0,
}
if (product.DataPubblicazione) {
productInfo.date_publishing = new Date(product.DataPubblicazione);
productInfo.date_pub = new Date(product.DataPubblicazione);
// convert data to timestamp
productInfo.date_publishing_ts = productInfo.date_publishing.getTime();
productInfo.date_pub_ts = productInfo.date_pub.getTime();
}
if (product.dataUltimoOrdine) {
productInfo.dataUltimoOrdine = new Date(product.dataUltimoOrdine);
@@ -897,10 +902,10 @@ router.post('/import', authenticate, async (req, res) => {
// Update ProductInfo
let risrecInfo = await ProductInfo.findOneAndUpdate({ code: productInfo.code }, { $set: productInfo }, { new: true, upsert: true });
let risrecInfo = await ProductInfo.findOneAndUpdate({ code: productInfo.code }, { $set: productInfo }, { new: true, upsert: false });
if (risrecInfo) {
imported++;
if (imported % 10 === 0)
if (imported % 50 === 0)
console.log('Importati... ', imported + '/' + numprod);
}
}
@@ -965,7 +970,7 @@ router.post('/import', authenticate, async (req, res) => {
let risrec = await Importamacro.findOneAndUpdate(queryprod, { $set: recmacro }, { new: true, upsert: true, strict: false });
if (risrec) {
imported++;
if (imported % 10 === 0)
if (imported % 50 === 0)
console.log('Importati su dir Temporanea ', imported);
}
@@ -1034,7 +1039,7 @@ router.post('/import', authenticate, async (req, res) => {
let versione = 0;
if (indprod % 10 === 0)
if (indprod % 50 === 0)
console.log(indprod + '/' + numprod);
@@ -1070,9 +1075,9 @@ router.post('/import', authenticate, async (req, res) => {
/*if (product.Data) {
productInfo.date_publishing = new Date(product.Data * 1000);
productInfo.date_pub = new Date(product.Data * 1000);
// convert data to timestamp
productInfo.date_publishing_ts = productInfo.date_publishing.getTime();
productInfo.date_pub_ts = productInfo.date_pub.getTime();
}*/
productInfo.name = productInfo.name.replace(/ - Usato$| - Nuovo$| - Epub$| - Ebook$| - Mobi$| - DVD$| - Streaming$| - Download$/, "");

View File

@@ -19,7 +19,7 @@ const { Reaction } = require('../models/reaction');
const globalTables = require('../tools/globalTables');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
router.post('/getlist', authenticate_noerror, async function (req, res, next) {

View File

@@ -5,7 +5,7 @@ const Subscription = require('../../models/subscribers');
const { Graduatoria } = require('../../models/graduatoria');
const { User } = require('../../models/user');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const tools = require('../../tools/general');

View File

@@ -8,7 +8,7 @@ const { authenticate } = require('../middleware/authenticate');
const { Booking } = require('../models/booking');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const sendemail = require('../sendemail');
@@ -56,7 +56,7 @@ router.post('/', authenticate, (req, res) => {
} else {
// save to database a new record
tools.mylog('save to database a new record');
booking._id = new ObjectID();
booking._id = new ObjectId();
return booking.save().then((writeresult) => {
let idobj = writeresult._id;
@@ -107,7 +107,7 @@ router.delete('/:id/:notify/:idapp', authenticate, (req, res) => {
//
// // tools.mylog('GET BOOKINGS : ', req.params);
//
// if (!ObjectID.isValid(userId)) {
// if (!ObjectId.isValid(userId)) {
// return res.status(404).send();
// }
//

View File

@@ -19,7 +19,7 @@ const Order = require('../models/order');
const Variant = require('../models/variant');
const { User } = require('../models/user');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
/*const Department = require('../models/Department')
const Category = require('../models/Category')
@@ -442,7 +442,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: ObjectId(idGasordine) // Compares the value to a specific ObjectId
}
}
}

View File

@@ -17,7 +17,7 @@ const { Account } = require('../models/account');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
async function getCircuitRecAdminsInfo(idapp, data) {

View File

@@ -16,7 +16,7 @@ const Subscription = require('../models/subscribers');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const { City } = require('../models/city');

View File

@@ -15,7 +15,7 @@ const telegrambot = require('../telegram/telegrambot');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
router.post('/', authenticate, async (req, res) => {
try {

View File

@@ -12,7 +12,8 @@ const sharp = require('sharp');
const { authenticate, authenticate_noerror } = require(
'../middleware/authenticate');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// const {ListaIngresso} = require('../models/listaingresso');
const { Graduatoria } = require('../models/graduatoria');
@@ -418,8 +419,8 @@ router.post('/settable', authenticate, async (req, res) => {
} else {
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined || mytablerec._id === '0')) {
mytablerec._id = new ObjectID();
mydata._id = new ObjectID();
mytablerec._id = new ObjectId();
mydata._id = new ObjectId();
mytablerec.isNew = true;
}
}
@@ -911,25 +912,62 @@ async function exportPage(idapp, pageId) {
}
};
async function upsertRecord(table, record, appId) {
async function upsertRecord(table, record, appId, newIdPage = null) {
let newId = null;
const existingRecord = await table.findOne({ idapp: appId, _id: record._id }); // Assumendo che `record` ha un ID
if (existingRecord) {
if (newIdPage && record.idPage) {
record.idPage = newIdPage;
}
const modif = await table.updateOne({ _id: record._id }, { $set: { ...record, idapp: appId } });
wasModified = modif.nModified > 0;
} else {
const ris = await table.create({
// Se sono sulla tabella mypages
if (table.modelName === 'MyPage') {
// Controlla se esiste già la pagina in questione
const existingRecPage = await table.findOne({ idapp: appId, path: record.path });
if (existingRecPage) {
// Esiste già ! quindi aggiorno questo record, e cancello tutti gli elementi precedenti !
delete record._id;
const modif = await table.updateOne({ _id: existingRecPage._id }, { $set: { ...record, idapp: appId } });
const tableElems = globalTables.getTableByTableName('myelems');
if (tableElems)
risdel = await tableElems.deleteMany({ idapp: appId, idPage: existingRecPage._id });
newId = existingRecPage._id.toString();
return { ImportedRecords: false, newId }; // Torna il numero di record importati (1 in questo caso)
}
}
// Se non esiste, allora la creo, con un id Nuovo !
const existingRecSameID = await table.findOne({ _id: record._id }); // Assumendo che `record` ha un ID
if (existingRecSameID) {
// Se
newId = new ObjectId();
record._id = newId;
}
if (newIdPage && record.idPage) {
record.idPage = newIdPage;
}
const newrec = {
...record,
idapp: appId,
});
};
const ris = await table.create(newrec);
wasModified = !!ris;
}
return wasModified; // Torna il numero di record importati (1 in questo caso)
return { ImportedRecords: wasModified, newId }; // Torna il numero di record importati (1 in questo caso)
}
async function importPage(req, idapp, jsonString) {
try {
console.log('INIZIO importPage');
// Parsing dei dati JSON
const myexp = JSON.parse(jsonString);
@@ -939,12 +977,15 @@ async function importPage(req, idapp, jsonString) {
return;
}
let totalImportedRecords = 0;
let newIdPage = null;
// Ciclo su ogni proprietà di myexp
const importCounts = []; // Array per memorizzare i conteggi di importazione
// Cicla prima sulle pagine
for (const key in myexp) {
if (myexp.hasOwnProperty(key)) {
let ImportedRecordstemp = 0;
const tableName = key;
// Verifica se la tabella esiste
@@ -954,24 +995,61 @@ async function importPage(req, idapp, jsonString) {
if (tableName === 'mypages') {
if (User.isEditor(req.user.perm)) {
for (const page of myexp.mypages) {
totalImportedRecords += await upsertRecord(table, page, idapp) ? 1 : 0;
const { ImportedRecords, newId } = await upsertRecord(table, page, idapp);
if (!newIdPage && newId) {
newIdPage = newId;
}
ImportedRecordstemp += ImportedRecords ? 1 : 0;
}
}
}
totalImportedRecords += ImportedRecordstemp;
}
if (ImportedRecordstemp > 0)
importCounts.push({ tableName, count: ImportedRecordstemp });
}
}
} else if (tableName === 'myelems') {
// Ciclo su ogni proprietà di myexp
for (const key in myexp) {
if (myexp.hasOwnProperty(key)) {
let ImportedRecordstemp = 0;
const tableName = key;
// Verifica se la tabella esiste
if (tableName) {
const table = globalTables.getTableByTableName(tableName);
if (tableName === 'myelems') {
if (User.isEditor(req.user.perm)) {
for (const elem of myexp.myelems) {
totalImportedRecords += await upsertRecord(table, elem, idapp) ? 1 : 0;
const { ImportedRecords, newId } = await upsertRecord(table, elem, idapp, newIdPage);
ImportedRecordstemp += ImportedRecords ? 1 : 0;
}
}
} else if (tableName === 'myusers') {
if (User.isManager(req.user.perm)) {
for (const user of myexp.myusers) {
totalImportedRecords += await upsertRecord(table, user, idapp) ? 1 : 0;
const { ImportedRecords, newId } = await upsertRecord(table, user, idapp);
ImportedRecordstemp += ImportedRecords ? 1 : 0;
}
}
} else if (table && (tableName !== 'mypages')) {
// Tutte le altre tabelle
if (User.isManager(req.user.perm)) {
for (const rec of myexp[key]) {
const { ImportedRecords, newId } = await upsertRecord(table, rec, idapp);
ImportedRecordstemp += ImportedRecords ? 1 : 0;
}
}
}
totalImportedRecords += ImportedRecordstemp;
if (ImportedRecordstemp > 0)
importCounts.push({ tableName, count: ImportedRecordstemp });
}
}
}
@@ -980,7 +1058,7 @@ async function importPage(req, idapp, jsonString) {
console.log(`Importazione completata con successo. Totale record importati: ${totalImportedRecords}`);
}
return { imported: totalImportedRecords };
return { imported: totalImportedRecords, importCounts };
} catch (error) {
console.error('Errore durante l\'importazione:', error);
@@ -2009,7 +2087,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate_noerror, async (req, res
if (req.user) {
const userId = req.user._id;
if (!ObjectID.isValid(userId)) {
if (!ObjectId.isValid(userId)) {
return res.status(404).send();
}

View File

@@ -2,7 +2,7 @@ const express = require('express');
const router = express.Router();
const IscrittiArcadei = require('../models/iscrittiArcadei');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const sendemail = require('../sendemail');

View File

@@ -2,7 +2,7 @@ const express = require('express');
const router = express.Router();
const IscrittiConacreis = require('../models/iscrittiConacreis');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const sendemail = require('../sendemail');

View File

@@ -8,7 +8,7 @@ const {authenticate} = require('../middleware/authenticate');
const {MyEvent} = require('../models/myevent');
const {ObjectID} = require('mongodb');
const {ObjectId} = require('mongodb');
const sendemail = require('../sendemail');
@@ -52,7 +52,7 @@ router.post('/', authenticate, (req, res) => {
} else {
// save to database a new record
tools.mylog('save to database a new record');
myevent._id = new ObjectID();
myevent._id = new ObjectId();
return myevent.save().then((writeresult) => {
let idobj = writeresult._id;
@@ -99,7 +99,7 @@ router.get('/:userId/:idapp/:sall', authenticate, (req, res) => {
// tools.mylog('GET myeventS : ', req.params);
if (!ObjectID.isValid(userId)) {
if (!ObjectId.isValid(userId)) {
return res.status(404).send();
}

View File

@@ -20,7 +20,7 @@ const { Reaction } = require('../models/reaction');
const globalTables = require('../tools/globalTables');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
//GET orders
router.post('/page', authenticate_noerror, function (req, res, next) {

View File

@@ -16,7 +16,7 @@ const _ = require('lodash');
const {MyGood} = require('../models/mygood');
var {User} = require('../models/user');
const {ObjectID} = require('mongodb');
const {ObjectId} = require('mongodb');
//GET orders
router.post('/page', authenticate, function(req, res, next) {

View File

@@ -14,7 +14,7 @@ const { MyGroup } = require('../models/mygroup');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
async function getGroupRecAdminsInfo(idapp, data) {

View File

@@ -16,7 +16,7 @@ const _ = require('lodash');
const {MySkill} = require('../models/myskill');
var {User} = require('../models/user');
const {ObjectID} = require('mongodb');
const {ObjectId} = require('mongodb');
//GET orders
router.post('/page', authenticate, function(req, res, next) {

View File

@@ -16,7 +16,7 @@ const Subscription = require('../models/subscribers');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const Product = require('../models/product');
const Order = require('../models/order');

View File

@@ -15,7 +15,7 @@ const { User } = require('../models/user');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
router.post('/', authenticate, (req, res) => {
@@ -83,7 +83,7 @@ router.patch('/:id', authenticate, (req, res) => {
tools.mylogshow('PATCH PROJECT: ', id);
if (!ObjectID.isValid(id)) {
if (!ObjectId.isValid(id)) {
tools.mylog('ERROR: id not VALID', id);
return res.status(404).send();
}
@@ -161,7 +161,7 @@ router.get('/:userId', authenticate, (req, res) => {
const idapp = req.query.idapp;
if (!ObjectID.isValid(userId)) {
if (!ObjectId.isValid(userId)) {
return res.status(404).send();
}
@@ -235,7 +235,7 @@ router.delete('/:id', authenticate, (req, res) => {
const hide = true;
if (!ObjectID.isValid(id)) {
if (!ObjectId.isValid(id)) {
return res.status(404).send();
}

View File

@@ -6,7 +6,7 @@ const { Reaction } = require('../models/reaction');
const { User } = require('../models/user');
const Hours = require('../models/hours');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const sendemail = require('../sendemail');

View File

@@ -19,7 +19,7 @@ const Hours = require('../models/hours');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
router.post('/load', authenticate, async (req, res) => {
let date_start = req.body.date_start;

View File

@@ -12,7 +12,7 @@ const { SendMsg } = require('../models/sendmsg');
const { SendNotif } = require('../models/sendnotif');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const sendemail = require('../sendemail');
@@ -40,7 +40,7 @@ router.post('/', authenticate, (req, res) => {
// console.log('fieldtochange', fieldtochange);
myrecmsg._id = new ObjectID();
myrecmsg._id = new ObjectId();
return myrecmsg.save()
.then((writeresult) => {
let idobj = writeresult._id;

View File

@@ -15,7 +15,7 @@ const mongoose = require('mongoose').set('debug', false)
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
// const { ExtraList } = require('../models/extralist');

View File

@@ -17,7 +17,7 @@ const { Settings } = require('../models/settings');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
router.get('/', (req, res) => {
@@ -39,7 +39,7 @@ router.get('/', (req, res) => {
};
const myrec = new Todo(todo);
myrec._id = new ObjectID();
myrec._id = new ObjectId();
const TodoOne = myrec.save().then((ris, err) => {
console.log('Err:', err);
@@ -49,7 +49,7 @@ router.get('/', (req, res) => {
const newrec = new Settings({ key: 'chiave1' });
newrec._id = new ObjectID();
newrec._id = new ObjectId();
newrec.idapp = '8';
newrec.save((err, rec) => {

View File

@@ -16,7 +16,7 @@ const Hours = require('../models/hours');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
router.post('/', authenticate, async (req, res) => {
@@ -93,7 +93,7 @@ router.patch('/:id', authenticate, (req, res) => {
// tools.mylogshow('PATCH TODO: ', id);
if (!ObjectID.isValid(id)) {
if (!ObjectId.isValid(id)) {
tools.mylog('ERROR: id not VALID', id);
return res.status(404).send();
}
@@ -160,7 +160,7 @@ router.get('/:userId', authenticate, (req, res) => {
// tools.mylog('GET TODOS : ', req.params);
if (!ObjectID.isValid(userId)) {
if (!ObjectId.isValid(userId)) {
return res.status(404).send();
}
@@ -187,7 +187,7 @@ router.get('/:userId', authenticate, (req, res) => {
router.get('/test', (req, res) => {
const todo = {
_id: new ObjectID(),
_id: new ObjectId(),
// category: "personal",
statustodo: 0,
completed_at: new Date(),
@@ -239,7 +239,7 @@ router.delete('/:id', authenticate, (req, res) => {
let hide = true;
if (!ObjectID.isValid(id)) {
if (!ObjectId.isValid(id)) {
return res.status(404).send();
}

View File

@@ -14,7 +14,7 @@ const { MyGroup } = require('../models/mygroup');
const _ = require('lodash');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
async function getGroupRecAdminsInfo(idapp, data) {

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') {

View File

@@ -9,7 +9,7 @@ const { decode } = require('entities');
const i18n = require('i18n');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const { Settings } = require('./models/settings');
const { TemplEmail } = require('./models/templemail');
const { Discipline } = require('./models/discipline');
@@ -574,7 +574,7 @@ module.exports = {
email: mylocalsconf.emailto,
hash,
});
myperson._id = new ObjectID();
myperson._id = new ObjectId();
} else {
myperson.name = mylocalsconf.name;
myperson.surname = mylocalsconf.surname;
@@ -937,7 +937,7 @@ module.exports = {
const updateml = await User.findOneAndUpdate({
idapp,
email: user.email,
}, { $set: { lastid_newstosent: ObjectID(id_newstosent) } }, { new: false });
}, { $set: { lastid_newstosent: ObjectId(id_newstosent) } }, { new: false });
//Delay for send email...
await tools.snooze(secpause);

View File

@@ -85,7 +85,7 @@ var mongoose = require('mongoose').set('debug', false);
mongoose.set('debug', false);
const { CfgServer } = require('./models/cfgserver');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const populate = require('./populate/populate');
const { Circuit } = require('./models/circuit');
@@ -338,7 +338,7 @@ async function mystart() {
function populateDBadmin() {
const cfgserv = [
{
_id: new ObjectID(),
_id: new ObjectId(),
idapp: '9',
chiave: 'vers',
userId: 'ALL',

View File

@@ -1,4 +1,4 @@
const {ObjectID} = require('mongodb');
const {ObjectId} = require('mongodb');
const jwt = require('jsonwebtoken');
const {Todo} = require('../../models/todo');
@@ -10,9 +10,9 @@ const tools = require('../../tools/general');
let myuserIdOne = '';
const userOneId = new ObjectID();
const userTwoId = new ObjectID();
// const userThreeId = new ObjectID();
const userOneId = new ObjectId();
const userTwoId = new ObjectId();
// const userThreeId = new ObjectId();
// let mypwdcrypt = bcrypt.hash(mypwdchiaro, bcrypt.genSaltSync(12))
// .then((hashedPassword) => {
@@ -82,11 +82,11 @@ const userjson = JSON.stringify(users[0]);
// console.log('userjson=', userjson)
const mynewID = new ObjectID();
const mynewID = new ObjectId();
const mongoose = require('mongoose').set('debug', false)
var ObjectId = mongoose.Types.ObjectId;
const { ObjectId } = require('mongodb');
const todos = [
{
@@ -106,7 +106,7 @@ const todos = [
progress: 0,
userId: users[0]._id,
}, {
_id: new ObjectID(),
_id: new ObjectId(),
category: ObjectId(mynewID),
statustodo: 0,
completed_at: new Date(),
@@ -121,7 +121,7 @@ const todos = [
progress: 0,
userId: users[1]._id,
}, {
_id: new ObjectID(),
_id: new ObjectId(),
category: ObjectId(mynewID),
statustodo: 0,
completed_at: new Date(),
@@ -136,7 +136,7 @@ const todos = [
progress: 0,
userId: users[2]._id,
}, { // RECORD CHE VERRA' UTILIZZATO PER AGGIUNGERE UN NUOVO TASK
_id: new ObjectID(),
_id: new ObjectId(),
category: ObjectId(mynewID),
statustodo: 0,
completed_at: new Date(),

View File

@@ -1,6 +1,6 @@
const expect = require('expect');
const request = require('supertest');
const {ObjectID} = require('mongodb');
const {ObjectId} = require('mongodb');
const {app} = require('../server');
const {Todo} = require('../models/todo');
@@ -317,7 +317,7 @@ if (testsingolo) {
});
it('FORBIDDEN ! should return [] if user not found', (done) => {
var hexId = new ObjectID().toHexString();
var hexId = new ObjectId().toHexString();
request(app).
get(`/todos/${hexId}`).
@@ -363,7 +363,7 @@ if (testsingolo) {
});
it('should return 404 if todo not found', (done) => {
var hexId = new ObjectID().toHexString();
var hexId = new ObjectId().toHexString();
request(app).
delete(`/todos/${hexId}`).

View File

@@ -16,7 +16,7 @@ const axios = require('axios');
const CryptoJS = require('crypto-js');
const Url = require('url-parse');
const { ObjectID, ObjectId } = require('mongodb');
const { ObjectId } = require('mongodb');
const shared_consts = require('./shared_nodejs');
@@ -845,7 +845,7 @@ module.exports = {
CloneRecordToNew(src) {
const myrec = Object.assign({}, src);
delete myrec._doc['_id'];
myrec._id = new ObjectID();
myrec._id = new ObjectId();
return myrec._doc;
},
@@ -2646,6 +2646,8 @@ module.exports = {
filtriadded.push({ 'profile.teleg_id_old': { $gt: 1 } });
if (params.filterand.includes(shared_consts.FILTER_USER_PROVINCE))
filtriadded.push({ 'profile.resid_province': { $exists: true } });
if (params.filterand.includes(shared_consts.FILTER_USER_SENZA_PROVINCE))
filtriadded.push({ 'profile.resid_province': { $exists: false } });
if (params.filterand.includes(shared_consts.FILTER_ATTIVI))
filtriadded.push({
$or: [
@@ -2715,10 +2717,10 @@ module.exports = {
let condition = {};
for (const myfilter of params.filtercustom) {
if (myfilter['userId']) {
myfilter['userId'] = ObjectID(myfilter['userId']);
myfilter['userId'] = ObjectId(myfilter['userId']);
}
if (myfilter['_idOBJ']) {
filtriadded.push({ _id: ObjectID(myfilter['_idOBJ']) });
filtriadded.push({ _id: ObjectId(myfilter['_idOBJ']) });
} else if (myfilter['dateTimeStart']) {
const gte = myfilter['dateTimeStart'].$gte;
const lte = myfilter['dateTimeStart'].$lte;
@@ -3398,7 +3400,7 @@ module.exports = {
for (let ind = 0; ind < arrrec.length; ind++) {
let newrec = new mythistable(arrrec[ind]);
newrec._id = new ObjectID();
newrec._id = new ObjectId();
newrec.idapp = idappdest;
try {

View File

@@ -8,7 +8,7 @@ require('../config/config');
require('../models/subscribers');
const { ObjectID } = require('mongodb');
const { ObjectId } = require('mongodb');
const { User } = require('../models/user');
const { MyGroup } = require('../models/mygroup');

View File

@@ -45,6 +45,7 @@ module.exports = {
FILTER_USER_SI_TELEGRAM_ID: 4194304,
FILTER_USER_WITHOUT_USERNAME_TELEGRAM: 8388608,
FILTER_USER_PROVINCE: 16777216,
FILTER_USER_SENZA_PROVINCE: 33554432,
OPTIONS_SEARCH_ONLY_FULL_WORDS: 1,
OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2,
@@ -245,7 +246,7 @@ module.exports = {
],
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
TABLES_CREATEDBY: ['mygroups', 'circuits', 'attivitas'],
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots', 'mygroups', 'circuits', 'attivitas', 'myelems', 'mypages'],
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots', 'mygroups', 'circuits', 'attivitas', 'myelems', 'mypages', 'productinfos', 'products'],
TABLES_FIELDS_DESCR_AND_CITY_AND_USER: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],

View File

@@ -1 +1 @@
1.1.12
1.1.14