- Cataloghi
- Import ed Export Pagine - ObjectID sostituita con ObjectId
This commit is contained in:
@@ -32,7 +32,7 @@ GCM_API_KEY=""
|
|||||||
PROD=0
|
PROD=0
|
||||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||||
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
||||||
TOKEN_LIFE=1m
|
TOKEN_LIFE=2h
|
||||||
REFRESH_TOKEN_LIFE=14d
|
REFRESH_TOKEN_LIFE=14d
|
||||||
FTPSERVER_HOST=139.162.166.31
|
FTPSERVER_HOST=139.162.166.31
|
||||||
FTPSERVER_PORT=21
|
FTPSERVER_PORT=21
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ var mongoose = require('mongoose').set('debug', false);
|
|||||||
mongoose.set('debug', false);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
const { CfgServer } = require('./models/cfgserver');
|
const { CfgServer } = require('./models/cfgserver');
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const populate = require('./populate/populate');
|
const populate = require('./populate/populate');
|
||||||
const { Circuit } = require('./models/circuit');
|
const { Circuit } = require('./models/circuit');
|
||||||
@@ -453,7 +453,7 @@ async function mystart() {
|
|||||||
function populateDBadmin() {
|
function populateDBadmin() {
|
||||||
const cfgserv = [
|
const cfgserv = [
|
||||||
{
|
{
|
||||||
_id: new ObjectID(),
|
_id: new ObjectId(),
|
||||||
idapp: '9',
|
idapp: '9',
|
||||||
chiave: 'vers',
|
chiave: 'vers',
|
||||||
userId: 'ALL',
|
userId: 'ALL',
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
@@ -24,7 +24,7 @@ const AccountSchema = new Schema({
|
|||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: function () {
|
default: function () {
|
||||||
return new ObjectID().toString();
|
return new ObjectId().toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
@@ -105,7 +105,7 @@ AccountSchema.statics.findAllIdApp = async function (idapp) {
|
|||||||
|
|
||||||
AccountSchema.pre('save', async function (next) {
|
AccountSchema.pre('save', async function (next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
this._id = new ObjectID().toString();
|
this._id = new ObjectId().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@@ -304,7 +304,7 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
|||||||
|
|
||||||
if (!myaccount && createifnotexist) {
|
if (!myaccount && createifnotexist) {
|
||||||
myaccount = new Account({
|
myaccount = new Account({
|
||||||
_id: new ObjectID().toString(),
|
_id: new ObjectId().toString(),
|
||||||
idapp,
|
idapp,
|
||||||
username: (!groupname && !contocom) ? username : '',
|
username: (!groupname && !contocom) ? username : '',
|
||||||
groupname,
|
groupname,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const {ObjectID} = require('mongodb');
|
const {ObjectId} = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const {ObjectID} = require('mongodb');
|
const {ObjectId} = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const { MyGroup } = require('./mygroup');
|
|||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
@@ -24,7 +24,7 @@ const AttivitaSchema = new Schema(
|
|||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: function () {
|
default: function () {
|
||||||
return new ObjectID().toString();
|
return new ObjectId().toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ mongoose.Promise = global.Promise;
|
|||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const { Movement } = require('../models/movement');
|
const { Movement } = require('../models/movement');
|
||||||
const { Account } = require('../models/account');
|
const { Account } = require('../models/account');
|
||||||
@@ -26,7 +26,7 @@ const CircuitSchema = new Schema({
|
|||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: function () {
|
default: function () {
|
||||||
return new ObjectID().toString();
|
return new ObjectId().toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
@@ -233,7 +233,7 @@ const CircuitSchema = new Schema({
|
|||||||
|
|
||||||
CircuitSchema.pre('save', async function (next) {
|
CircuitSchema.pre('save', async function (next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
this._id = new ObjectID().toString();
|
this._id = new ObjectId().toString();
|
||||||
|
|
||||||
this.date_created = new Date();
|
this.date_created = new Date();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const _ = require('lodash');
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const { Settings } = require('./settings');
|
const { Settings } = require('./settings');
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ function addRecGraduatoria(idapp, ingr, index) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let rec = new Graduatoria({
|
let rec = new Graduatoria({
|
||||||
_id: new ObjectID(),
|
_id: new ObjectId(),
|
||||||
idapp,
|
idapp,
|
||||||
idListaIngresso: ingr._id,
|
idListaIngresso: ingr._id,
|
||||||
ind_order: ingr.ind_order,
|
ind_order: ingr.ind_order,
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ mongoose.plugin(schema => {
|
|||||||
schema.options.usePushEach = true
|
schema.options.usePushEach = true
|
||||||
});
|
});
|
||||||
|
|
||||||
var ObjectId = mongoose.Types.ObjectId;
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
|
||||||
|
|
||||||
const HoursSchema = new Schema({
|
const HoursSchema = new Schema({
|
||||||
idapp: {
|
idapp: {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const tools = require('../tools/general');
|
|||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const tools = require('../tools/general');
|
|||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const tools = require('../tools/general');
|
|||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const tools = require('../tools/general');
|
|||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const {ObjectID} = require('mongodb');
|
const {ObjectId} = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
const { Account } = require('../models/account');
|
const { Account } = require('../models/account');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
@@ -18,7 +18,7 @@ const MovementSchema = new Schema({
|
|||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: function () {
|
default: function () {
|
||||||
return new ObjectID().toString();
|
return new ObjectId().toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { Reaction } = require('./reaction');
|
const { Reaction } = require('./reaction');
|
||||||
@@ -24,7 +24,7 @@ const MyBachecaSchema = new Schema({
|
|||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: function () {
|
default: function () {
|
||||||
return new ObjectID().toString();
|
return new ObjectId().toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const mongoose = require('mongoose').set('debug', false)
|
|||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
const { ObjectID, ObjectId } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const { MySchedaSchema, IDimensioni, IImg, IText, IAreaDiStampa } = require('../models/myscheda');
|
const { MySchedaSchema, IDimensioni, IImg, IText, IAreaDiStampa } = require('../models/myscheda');
|
||||||
|
|
||||||
@@ -246,7 +246,7 @@ const MyElemSchema = new Schema({
|
|||||||
|
|
||||||
MyElemSchema.pre('save', async function (next) {
|
MyElemSchema.pre('save', async function (next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
this._id = new ObjectID();
|
this._id = new ObjectId();
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@@ -280,16 +280,19 @@ MyElemSchema.statics.SetIdPageInsteadThePah = async function (idapp) {
|
|||||||
|
|
||||||
// Aggiorna MyElem utilizzando la mappa
|
// Aggiorna MyElem utilizzando la mappa
|
||||||
for (const [path, id] of Object.entries(pathToIdMap)) {
|
for (const [path, id] of Object.entries(pathToIdMap)) {
|
||||||
await MyElem.updateMany(
|
if (path) {
|
||||||
{ path: path }, // Condizione per aggiornare dove il path corrisponde
|
await MyElem.updateMany(
|
||||||
{
|
{ idapp },
|
||||||
$set: {
|
{ path: path }, // Condizione per aggiornare dove il path corrisponde
|
||||||
idPage: id,
|
{
|
||||||
oldpath: path,
|
$set: {
|
||||||
},
|
idPage: id,
|
||||||
$unset: { path: "" } // Rimuove il campo path
|
oldpath: path,
|
||||||
} // Imposta IdPage all'ID del documento corrispondente
|
},
|
||||||
);
|
$unset: { path: "" } // Rimuove il campo path
|
||||||
|
} // Imposta IdPage all'ID del documento corrispondente
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false) {
|
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.');
|
console.log('Aggiornamenti effettuati con successo.');
|
||||||
return 'Aggiornamenti effettuati con successo.';
|
return 'Aggiornamenti effettuati con successo.';
|
||||||
@@ -340,7 +358,9 @@ MyElemSchema.statics.findAllIdApp = async function (idapp) {
|
|||||||
|
|
||||||
const myfind = { 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) {
|
MyElemSchema.statics.findallSchedeTemplate = async function (idapp) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const {ObjectID} = require('mongodb');
|
const {ObjectId} = require('mongodb');
|
||||||
|
|
||||||
const {Settings} = require('./settings');
|
const {Settings} = require('./settings');
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const { MyGroup } = require('./mygroup');
|
|||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const shared_consts = require('../tools/shared_nodejs');
|
|||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = 'F';
|
mongoose.level = 'F';
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
@@ -19,7 +19,7 @@ const MyGroupSchema = new Schema({
|
|||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: function () {
|
default: function () {
|
||||||
return new ObjectID().toString();
|
return new ObjectId().toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const { Reaction } = require('./reaction');
|
|||||||
const { MyGroup } = require('./mygroup');
|
const { MyGroup } = require('./mygroup');
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const mongoose = require('mongoose').set('debug', false)
|
|||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
const { ObjectID, ObjectId } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const { MyGroup } = require('./mygroup');
|
|||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
@@ -24,7 +24,7 @@ const MySkillSchema = new Schema(
|
|||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: function () {
|
default: function () {
|
||||||
return new ObjectID().toString();
|
return new ObjectId().toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const Schema = mongoose.Schema;
|
|||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
@@ -377,7 +377,7 @@ module.exports.updateTotals = function (order) {
|
|||||||
|
|
||||||
module.exports.getTotalOrderById = async function (id) {
|
module.exports.getTotalOrderById = async function (id) {
|
||||||
const query = [
|
const query = [
|
||||||
{ $match: { _id: ObjectID(id) } },
|
{ $match: { _id: ObjectId(id) } },
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'products',
|
from: 'products',
|
||||||
@@ -660,7 +660,7 @@ module.exports.GeneraCSVOrdineProdotti = async function () {
|
|||||||
const myidGasordine = '65c2a8cc379ee4f57e865ee7';
|
const myidGasordine = '65c2a8cc379ee4f57e865ee7';
|
||||||
|
|
||||||
const myquery = [
|
const myquery = [
|
||||||
{ $match: { idGasordine: ObjectID(myidGasordine) } },
|
{ $match: { idGasordine: ObjectId(myidGasordine) } },
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'products',
|
from: 'products',
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const Cart = require('../models/cart');
|
|||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const OrdersCartSchema = new Schema({
|
const OrdersCartSchema = new Schema({
|
||||||
idapp: {
|
idapp: {
|
||||||
@@ -198,7 +198,7 @@ module.exports.getRecCartByUserId = async function (uid, idapp, numorder) {
|
|||||||
|
|
||||||
module.exports.getOrdersCartById = async function (id) {
|
module.exports.getOrdersCartById = async function (id) {
|
||||||
|
|
||||||
let query = { _id: ObjectID(id) };
|
let query = { _id: ObjectId(id) };
|
||||||
|
|
||||||
const arrris = await OrdersCart.getOrdersCartByQuery(query);
|
const arrris = await OrdersCart.getOrdersCartByQuery(query);
|
||||||
let myrec = arrris && arrris.length > 0 ? arrris[0] : null;
|
let myrec = arrris && arrris.length > 0 ? arrris[0] : null;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const Scontistica = require('../models/scontistica');
|
|||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
@@ -212,6 +212,15 @@ const productSchema = new Schema({
|
|||||||
gas_name: {
|
gas_name: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
date_created: {
|
||||||
|
type: Date,
|
||||||
|
default: Date.now
|
||||||
|
},
|
||||||
|
date_updated: {
|
||||||
|
type: Date,
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var Product = module.exports = mongoose.model('Product', productSchema);
|
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)) {
|
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 = {
|
const objDelete = {
|
||||||
cat_name: 1,
|
cat_name: 1,
|
||||||
@@ -1005,7 +1014,7 @@ module.exports.singlerecconvert_AfterImport_AndSave = async function (idapp, pro
|
|||||||
gas_name: 1,
|
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) {
|
if (ris && ris.nModified > 0) {
|
||||||
console.log('Modificato: ', objtoset.name);
|
console.log('Modificato: ', objtoset.name);
|
||||||
|
|||||||
@@ -123,20 +123,25 @@ const productInfoSchema = new Schema({
|
|||||||
collezione: {
|
collezione: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
date_publishing: {
|
date_pub: {
|
||||||
type: Date,
|
type: Date,
|
||||||
},
|
},
|
||||||
date_publishing_ts: {
|
date_pub_ts: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
productTypes: [{
|
productTypes: [{
|
||||||
type: Number,
|
type: Number,
|
||||||
}],
|
}],
|
||||||
totaleVenduti: Number,
|
|
||||||
venditeLastM: Number,
|
date_updated: {
|
||||||
venditeLast6M: Number,
|
type: Date,
|
||||||
venditeLastY: Number,
|
},
|
||||||
venditeLast2Y: Number,
|
|
||||||
|
totVen: Number,
|
||||||
|
vLastM: Number,
|
||||||
|
vLast6M: Number,
|
||||||
|
vLastY: Number,
|
||||||
|
vLast2Y: Number,
|
||||||
dataUltimoOrdine: Date,
|
dataUltimoOrdine: Date,
|
||||||
rank3M: Number,
|
rank3M: Number,
|
||||||
rank6M: Number,
|
rank6M: Number,
|
||||||
@@ -152,7 +157,12 @@ const productInfoSchema = new Schema({
|
|||||||
var productInfo = module.exports = mongoose.model('ProductInfo', productInfoSchema);
|
var productInfo = module.exports = mongoose.model('ProductInfo', productInfoSchema);
|
||||||
|
|
||||||
module.exports.getFieldsForSearch = function () {
|
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) {
|
module.exports.executeQueryTable = function (idapp, params) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
|
|||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const tools = require('../tools/general');
|
|||||||
|
|
||||||
// const CatAI = require('./catai');
|
// const CatAI = require('./catai');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const shared_consts = require('../tools/shared_nodejs');
|
|||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const Schema = mongoose.Schema;
|
|||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = 'F';
|
|||||||
|
|
||||||
const i18n = require('i18n');
|
const i18n = require('i18n');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
const server_constants = require('../tools/server_constants');
|
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) {
|
if (newstatus > 0) {
|
||||||
myrecnotif.status = newstatus;
|
myrecnotif.status = newstatus;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
@@ -129,7 +129,7 @@ SettingsSchema.statics.setKeyNum = async function (idapp, key, value) {
|
|||||||
let myrec = await Settings.findOne({ idapp, key });
|
let myrec = await Settings.findOne({ idapp, key });
|
||||||
if (!myrec) {
|
if (!myrec) {
|
||||||
myrec = new Settings({ key });
|
myrec = new Settings({ key });
|
||||||
myrec._id = new ObjectID();
|
myrec._id = new ObjectId();
|
||||||
myrec.idapp = idapp;
|
myrec.idapp = idapp;
|
||||||
myrec.type = tools.FieldType.number;
|
myrec.type = tools.FieldType.number;
|
||||||
myrec.value_num = value;
|
myrec.value_num = value;
|
||||||
@@ -149,7 +149,7 @@ SettingsSchema.statics.setBool = async function (idapp, key, valbool) {
|
|||||||
let myrec = await Settings.findOne({ idapp, key });
|
let myrec = await Settings.findOne({ idapp, key });
|
||||||
if (!myrec) {
|
if (!myrec) {
|
||||||
myrec = new Settings({ key });
|
myrec = new Settings({ key });
|
||||||
myrec._id = new ObjectID();
|
myrec._id = new ObjectId();
|
||||||
myrec.idapp = idapp;
|
myrec.idapp = idapp;
|
||||||
myrec.type = tools.FieldType.boolean;
|
myrec.type = tools.FieldType.boolean;
|
||||||
myrec.value_bool = valbool;
|
myrec.value_bool = valbool;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
mongoose.set('debug', false);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ module.exports.createFirstUserAdmin = async function () {
|
|||||||
const utenteadmin = { idapp: '13', username: telegrambot.ADMIN_USER_SERVER };
|
const utenteadmin = { idapp: '13', username: telegrambot.ADMIN_USER_SERVER };
|
||||||
|
|
||||||
const newuser = new User(utenteadmin);
|
const newuser = new User(utenteadmin);
|
||||||
newuser._id = new ObjectID();
|
newuser._id = new ObjectId();
|
||||||
newuser.idapp = mysite.idapp;
|
newuser.idapp = mysite.idapp;
|
||||||
newuser.profile.mygroups = [];
|
newuser.profile.mygroups = [];
|
||||||
newuser.profile.mycircuits = [];
|
newuser.profile.mycircuits = [];
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ const { MyGroup } = require('../models/mygroup');
|
|||||||
const { Settings } = require('../models/settings');
|
const { Settings } = require('../models/settings');
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
var ObjectId = mongoose.Types.ObjectId;
|
|
||||||
|
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const Schema = mongoose.Schema;
|
|||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mongoose.level = "F";
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ var mongoose = require('mongoose').set('debug', false)
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
var { Project } = require('./project');
|
var { Project } = require('./project');
|
||||||
@@ -108,7 +108,7 @@ TodoSchema.statics.findByUserIdAndIdParent = function (userId, category, phase =
|
|||||||
var Todo = this;
|
var Todo = this;
|
||||||
|
|
||||||
let tofind = {
|
let tofind = {
|
||||||
category: ObjectID(category),
|
category: ObjectId(category),
|
||||||
$or:
|
$or:
|
||||||
[{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
|
[{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const { Circuit } = require('../models/circuit');
|
|||||||
const { Account } = require('../models/account');
|
const { Account } = require('../models/account');
|
||||||
const { Movement } = require('../models/movement');
|
const { Movement } = require('../models/movement');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const i18n = require('i18n');
|
const i18n = require('i18n');
|
||||||
|
|
||||||
@@ -6199,7 +6199,7 @@ UserSchema.statics.addNewSite = async function (idappPass, body) {
|
|||||||
|
|
||||||
// Nessun Sito Installato e Nessun Utente installato !
|
// Nessun Sito Installato e Nessun Utente installato !
|
||||||
let myuser = new User();
|
let myuser = new User();
|
||||||
myuser._id = new ObjectID();
|
myuser._id = new ObjectId();
|
||||||
myuser.idapp = idapp;
|
myuser.idapp = idapp;
|
||||||
myuser.email = body.email;
|
myuser.email = body.email;
|
||||||
myuser.username = body.username;
|
myuser.username = body.username;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
const cartModel = require('../models/cart')
|
const cartModel = require('../models/cart')
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const Gasordine = require('../models/gasordine');
|
const Gasordine = require('../models/gasordine');
|
||||||
|
|
||||||
|
|||||||
@@ -1,92 +1,92 @@
|
|||||||
const {ObjectID} = require('mongodb');
|
const {ObjectId} = require('mongodb');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("615a353c002c8298f4495be7"),
|
"_id" : ObjectId("615a353c002c8298f4495be7"),
|
||||||
"idapp" : "1",
|
"idapp" : "1",
|
||||||
"label" : "Dono",
|
"label" : "Dono",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("61bc466567de9a1f54b25494"),
|
"_id" : ObjectId("61bc466567de9a1f54b25494"),
|
||||||
"idapp" : "1",
|
"idapp" : "1",
|
||||||
"label" : "Offerta Libera",
|
"label" : "Offerta Libera",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("61bc454867de9a1f54b25462"),
|
"_id" : ObjectId("61bc454867de9a1f54b25462"),
|
||||||
"idapp" : "1",
|
"idapp" : "1",
|
||||||
"label" : "Baratto (scambio Beni o Servizi)",
|
"label" : "Baratto (scambio Beni o Servizi)",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("61bc482667de9a1f54b2549c"),
|
"_id" : ObjectId("61bc482667de9a1f54b2549c"),
|
||||||
"idapp" : "1",
|
"idapp" : "1",
|
||||||
"label" : "Scambio Lavoro",
|
"label" : "Scambio Lavoro",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("61bc482667de9a1f54b2649c"),
|
"_id" : ObjectId("61bc482667de9a1f54b2649c"),
|
||||||
"idapp" : "1",
|
"idapp" : "1",
|
||||||
"label" : "Monete Alternative",
|
"label" : "Monete Alternative",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("61bc482667de9a1f54b3549e"),
|
"_id" : ObjectId("61bc482667de9a1f54b3549e"),
|
||||||
"idapp" : "1",
|
"idapp" : "1",
|
||||||
"label" : "Euro",
|
"label" : "Euro",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("615a353c002c8298f4495bf7"),
|
"_id" : ObjectId("615a353c002c8298f4495bf7"),
|
||||||
"idapp" : "12",
|
"idapp" : "12",
|
||||||
"label" : "Dono",
|
"label" : "Dono",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("61bc466567de9a1f54b254f4"),
|
"_id" : ObjectId("61bc466567de9a1f54b254f4"),
|
||||||
"idapp" : "12",
|
"idapp" : "12",
|
||||||
"label" : "Offerta Libera",
|
"label" : "Offerta Libera",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("61bc454867de9a1f54b254f2"),
|
"_id" : ObjectId("61bc454867de9a1f54b254f2"),
|
||||||
"idapp" : "12",
|
"idapp" : "12",
|
||||||
"label" : "Baratto",
|
"label" : "Baratto",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("61bc482667de9a1f54b25412"),
|
"_id" : ObjectId("61bc482667de9a1f54b25412"),
|
||||||
"idapp" : "12",
|
"idapp" : "12",
|
||||||
"label" : "Scambio Lavoro",
|
"label" : "Scambio Lavoro",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("61bc482667de9a1f64b254ab"),
|
"_id" : ObjectId("61bc482667de9a1f64b254ab"),
|
||||||
"idapp" : "12",
|
"idapp" : "12",
|
||||||
"label" : "Monete Alternative",
|
"label" : "Monete Alternative",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("61bc482667de9a1f64b254fb"),
|
"_id" : ObjectId("61bc482667de9a1f64b254fb"),
|
||||||
"idapp" : "12",
|
"idapp" : "12",
|
||||||
"label" : "Euro",
|
"label" : "Euro",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("5dbc6b0801234f629f75e98d"),
|
"_id" : ObjectId("5dbc6b0801234f629f75e98d"),
|
||||||
"idapp" : "2",
|
"idapp" : "2",
|
||||||
"__v" : 0,
|
"__v" : 0,
|
||||||
"label" : "Offerta Libera"
|
"label" : "Offerta Libera"
|
||||||
},
|
},
|
||||||
/* 2 */
|
/* 2 */
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("5dbc6b1001234f629f75e98e"),
|
"_id" : ObjectId("5dbc6b1001234f629f75e98e"),
|
||||||
"idapp" : "2",
|
"idapp" : "2",
|
||||||
"__v" : 0,
|
"__v" : 0,
|
||||||
"label" : "Ingresso Gratuito"
|
"label" : "Ingresso Gratuito"
|
||||||
@@ -94,7 +94,7 @@ module.exports = {
|
|||||||
|
|
||||||
/* 3 */
|
/* 3 */
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("5dbc6b1801234f629f75e98f"),
|
"_id" : ObjectId("5dbc6b1801234f629f75e98f"),
|
||||||
"idapp" : "2",
|
"idapp" : "2",
|
||||||
"__v" : 0,
|
"__v" : 0,
|
||||||
"label" : "Contributo",
|
"label" : "Contributo",
|
||||||
@@ -103,13 +103,13 @@ module.exports = {
|
|||||||
|
|
||||||
/* 4 */
|
/* 4 */
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("5dbc6b3001234f629f75e990"),
|
"_id" : ObjectId("5dbc6b3001234f629f75e990"),
|
||||||
"idapp" : "2",
|
"idapp" : "2",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("602c315137d9f0738ded312f"),
|
"_id" : ObjectId("602c315137d9f0738ded312f"),
|
||||||
"idapp" : "10",
|
"idapp" : "10",
|
||||||
"__v" : 0,
|
"__v" : 0,
|
||||||
"label" : "Contributo",
|
"label" : "Contributo",
|
||||||
@@ -118,7 +118,7 @@ module.exports = {
|
|||||||
|
|
||||||
/* 7 */
|
/* 7 */
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("602c316037d9f0738ded3132"),
|
"_id" : ObjectId("602c316037d9f0738ded3132"),
|
||||||
"idapp" : "10",
|
"idapp" : "10",
|
||||||
"__v" : 0,
|
"__v" : 0,
|
||||||
"label" : "Gratuito"
|
"label" : "Gratuito"
|
||||||
@@ -126,61 +126,61 @@ module.exports = {
|
|||||||
|
|
||||||
/* 8 */
|
/* 8 */
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("60514b3f733ce468d09366f2"),
|
"_id" : ObjectId("60514b3f733ce468d09366f2"),
|
||||||
"idapp" : "10",
|
"idapp" : "10",
|
||||||
"__v" : 0,
|
"__v" : 0,
|
||||||
"label" : "Evento ONLINE Gratuito"
|
"label" : "Evento ONLINE Gratuito"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("515a353c002c8298f4495bf7"),
|
"_id" : ObjectId("515a353c002c8298f4495bf7"),
|
||||||
"idapp" : "13",
|
"idapp" : "13",
|
||||||
"label" : "Dono",
|
"label" : "Dono",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("51bc466567de9a1f54b254f4"),
|
"_id" : ObjectId("51bc466567de9a1f54b254f4"),
|
||||||
"idapp" : "13",
|
"idapp" : "13",
|
||||||
"label" : "Offerta Libera",
|
"label" : "Offerta Libera",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("51bc454867de9a1f54b254f2"),
|
"_id" : ObjectId("51bc454867de9a1f54b254f2"),
|
||||||
"idapp" : "13",
|
"idapp" : "13",
|
||||||
"label" : "Baratto",
|
"label" : "Baratto",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("51bc482667de9a1f54b25412"),
|
"_id" : ObjectId("51bc482667de9a1f54b25412"),
|
||||||
"idapp" : "13",
|
"idapp" : "13",
|
||||||
"label" : "Scambio Lavoro",
|
"label" : "Scambio Lavoro",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("51bc482667de9a1f64b254ab"),
|
"_id" : ObjectId("51bc482667de9a1f64b254ab"),
|
||||||
"idapp" : "13",
|
"idapp" : "13",
|
||||||
"label" : "Monete Alternative",
|
"label" : "Monete Alternative",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("51bc482667de9a1f64b254ac"),
|
"_id" : ObjectId("51bc482667de9a1f64b254ac"),
|
||||||
"idapp" : "13",
|
"idapp" : "13",
|
||||||
"label" : "RIS",
|
"label" : "RIS",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("51bc482667de9a1f64b254fb"),
|
"_id" : ObjectId("51bc482667de9a1f64b254fb"),
|
||||||
"idapp" : "13",
|
"idapp" : "13",
|
||||||
"label" : "Euro",
|
"label" : "Euro",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("51bc482667de9a1f64b254ff"),
|
"_id" : ObjectId("51bc482667de9a1f64b254ff"),
|
||||||
"idapp" : "13",
|
"idapp" : "13",
|
||||||
"label" : "Bitcoin",
|
"label" : "Bitcoin",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_id" : ObjectID("51bc482667de9a1f64b255ff"),
|
"_id" : ObjectId("51bc482667de9a1f64b255ff"),
|
||||||
"idapp" : "13",
|
"idapp" : "13",
|
||||||
"label" : "Banca del Tempo",
|
"label" : "Banca del Tempo",
|
||||||
"__v" : 0
|
"__v" : 0
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
_id: ObjectID("115a353c002c298f44900010"),
|
_id: ObjectId("115a353c002c298f44900010"),
|
||||||
idapp: 18,
|
idapp: 18,
|
||||||
ask: [
|
ask: [
|
||||||
{ descr: 'Scegli quanti punti', value: 'numpunti' },
|
{ descr: 'Scegli quanti punti', value: 'numpunti' },
|
||||||
@@ -13,7 +13,7 @@ module.exports = {
|
|||||||
output_type: 'ELENCO',
|
output_type: 'ELENCO',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_id: ObjectID("115a353c002c298f44900020"),
|
_id: ObjectId("115a353c002c298f44900020"),
|
||||||
idapp: 18,
|
idapp: 18,
|
||||||
ask: [
|
ask: [
|
||||||
{ descr: 'Numeri di righe', value: 'numrighe', min: 1, max: 100 },
|
{ descr: 'Numeri di righe', value: 'numrighe', min: 1, max: 100 },
|
||||||
@@ -23,7 +23,7 @@ module.exports = {
|
|||||||
output_type: 'ELENCO',
|
output_type: 'ELENCO',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_id: ObjectID("115a353c002c829f44900030"),
|
_id: ObjectId("115a353c002c829f44900030"),
|
||||||
idapp: 18,
|
idapp: 18,
|
||||||
ask: [],
|
ask: [],
|
||||||
descr: 'Estrai le cose importanti dell\'articolo',
|
descr: 'Estrai le cose importanti dell\'articolo',
|
||||||
@@ -31,7 +31,7 @@ module.exports = {
|
|||||||
output_type: '',
|
output_type: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_id: ObjectID("115a353c002c8298f4900040"),
|
_id: ObjectId("115a353c002c8298f4900040"),
|
||||||
idapp: 18,
|
idapp: 18,
|
||||||
ask: [],
|
ask: [],
|
||||||
descr: 'Dammi degli Emoji',
|
descr: 'Dammi degli Emoji',
|
||||||
@@ -40,7 +40,7 @@ module.exports = {
|
|||||||
output_type: '',
|
output_type: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_id: ObjectID("115a353c002c298f44900050"),
|
_id: ObjectId("115a353c002c298f44900050"),
|
||||||
idapp: 18,
|
idapp: 18,
|
||||||
ask: [
|
ask: [
|
||||||
{ descr: 'Scegli quanti Punti', value: 'numpunti' },
|
{ descr: 'Scegli quanti Punti', value: 'numpunti' },
|
||||||
@@ -50,13 +50,13 @@ module.exports = {
|
|||||||
output_type: 'ELENCO',
|
output_type: 'ELENCO',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_id: ObjectID("115a353c002c898f44900060"),
|
_id: ObjectId("115a353c002c898f44900060"),
|
||||||
idapp: 18,
|
idapp: 18,
|
||||||
descr: 'Scaletta punti',
|
descr: 'Scaletta punti',
|
||||||
query: 'Mi fai una scaletta di punti che potrei affrontare durante il webinar.',
|
query: 'Mi fai una scaletta di punti che potrei affrontare durante il webinar.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_id: ObjectID("115a353c002c829f44900070"),
|
_id: ObjectId("115a353c002c829f44900070"),
|
||||||
idapp: 18,
|
idapp: 18,
|
||||||
descr: 'Elenchi Puntati',
|
descr: 'Elenchi Puntati',
|
||||||
query: 'Mi trasformi questo testo in elenchi puntati? {testo}',
|
query: 'Mi trasformi questo testo in elenchi puntati? {testo}',
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const { Account } = require('../models/account');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
async function getCircuitRecAdminsInfo(idapp, data) {
|
async function getCircuitRecAdminsInfo(idapp, data) {
|
||||||
|
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
let imported = 0;
|
let imported = 0;
|
||||||
let errors = 0;
|
let errors = 0;
|
||||||
|
|
||||||
const ripopola = false;
|
const ripopola = true;
|
||||||
|
|
||||||
dataObjects = null;
|
dataObjects = null;
|
||||||
|
|
||||||
@@ -650,10 +650,12 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
if (myarr && ripopola) {
|
if (myarr && ripopola) {
|
||||||
|
|
||||||
|
console.log('*** INIZIO IMPORT RIPOPOLAMENTO ... ', myarr.length);
|
||||||
|
|
||||||
// Cancella la collection ImportaMacros
|
// Cancella la collection ImportaMacros
|
||||||
await ImportaDescr.deleteMany({ idapp });
|
await ImportaDescr.deleteMany({ idapp });
|
||||||
|
|
||||||
// Aggiungi i record su ImportaMacros
|
// Aggiungi i record su ImportaDescr
|
||||||
for (const recinv of myarr) {
|
for (const recinv of myarr) {
|
||||||
let isnuovo = false
|
let isnuovo = false
|
||||||
let setta = false
|
let setta = false
|
||||||
@@ -669,12 +671,15 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
let queryprod = { idapp, code: recmacro._id };
|
let queryprod = { idapp, code: recmacro._id };
|
||||||
|
|
||||||
try {
|
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) {
|
if (risrec) {
|
||||||
imported++;
|
imported++;
|
||||||
// if (imported > 1000)
|
// if (imported > 1000)
|
||||||
// break;
|
// break;
|
||||||
if (imported % 10 === 0)
|
if (imported % 50 === 0)
|
||||||
console.log('importato ', imported, 'su ', myarr.length);
|
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)
|
// IMPOSTA I VALORI SOLO SE NON ESISTONO ! ALTRIMENTI LASCIA QUELLI GIA' IMPORTATI (O MODIFICATI)
|
||||||
|
|
||||||
if (getvalueByJsonText(product.url)) {
|
if (getvalueByJsonText(product.url)) {
|
||||||
if (!myproductInfo.link_macro)
|
if ((myproductInfo && !myproductInfo.link_macro) || !myproductInfo)
|
||||||
productInfo.link_macro = getvalueByJsonText(product.url);
|
productInfo.link_macro = getvalueByJsonText(product.url);
|
||||||
}
|
}
|
||||||
if (getvalueByJsonText(product.descrizione)) {
|
if (getvalueByJsonText(product.descrizione)) {
|
||||||
if (!myproductInfo.descrizione_completa_macro)
|
if ((myproductInfo && !myproductInfo.descrizione_breve_macro) || !myproductInfo)
|
||||||
productInfo.descrizione_breve_macro = getvalueByJsonText(product.descrizione);
|
productInfo.descrizione_breve_macro = getvalueByJsonText(product.descrizione);
|
||||||
}
|
}
|
||||||
if (getvalueByJsonText(product.descrizione_completa)) {
|
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)
|
productInfo.descrizione_completa_macro = getvalueByJsonText(product.descrizione_completa)
|
||||||
}
|
}
|
||||||
if (getvalueByJsonText(product.sottotitolo)) {
|
if (getvalueByJsonText(product.sottotitolo)) {
|
||||||
if (!myproductInfo.sottotitolo)
|
if ((myproductInfo && !myproductInfo.sottotitolo) || !myproductInfo)
|
||||||
productInfo.sottotitolo = getvalueByJsonText(product.sottotitolo);
|
productInfo.sottotitolo = getvalueByJsonText(product.sottotitolo);
|
||||||
}
|
}
|
||||||
if (getvalueByJsonText(product.titolo)) {
|
if (getvalueByJsonText(product.titolo)) {
|
||||||
if (!myproductInfo.name)
|
if ((myproductInfo && !myproductInfo.name) || !myproductInfo)
|
||||||
productInfo.name = getvalueByJsonText(product.titolo);
|
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 });
|
let risrecInfo = await ProductInfo.findOneAndUpdate({ code: productInfo.code }, { $set: productInfo }, { new: true, upsert: true });
|
||||||
|
|
||||||
indprod++;
|
indprod++;
|
||||||
if (indprod % 10 === 0)
|
if (indprod % 50 === 0)
|
||||||
console.log(indprod + '/' + numprod);
|
console.log(indprod + '/' + numprod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -783,14 +788,14 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
if (dataObjects && dataObjects[0]) {
|
if (dataObjects && dataObjects[0]) {
|
||||||
// Cancella la collection ImportaMacros
|
// Cancella la collection ImportaIsbn
|
||||||
await ImportaIsbn.deleteMany({ idapp });
|
await ImportaIsbn.deleteMany({ idapp });
|
||||||
|
|
||||||
const numtot = dataObjects[0].length
|
const numtot = dataObjects[0].length
|
||||||
|
|
||||||
console.log('Numero di RECORD da Importare = ', numtot);
|
console.log('Numero di RECORD da Importare = ', numtot);
|
||||||
|
|
||||||
// Aggiungi i record su ImportaMacros
|
// Aggiungi i record su ImportaIsbn
|
||||||
for (const recinv of dataObjects[0]) {
|
for (const recinv of dataObjects[0]) {
|
||||||
let recmacro = recinv;
|
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 });
|
let risrec = await ImportaIsbn.findOneAndUpdate(queryprod, { $set: recmacro }, { new: true, upsert: true, strict: false });
|
||||||
if (risrec) {
|
if (risrec) {
|
||||||
imported++;
|
imported++;
|
||||||
if ((imported % 10) === 0)
|
if ((imported % 50) === 0)
|
||||||
console.log('Importati dir TEMPORANEA ... ', imported + '/' + numtot);
|
console.log('Importati dir TEMPORANEA ... ', imported + '/' + numtot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -836,11 +841,11 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
// Rimuove prima tutti i valori precedenti
|
// Rimuove prima tutti i valori precedenti
|
||||||
let risupdate = await ProductInfo.updateMany({ idapp }, {
|
let risupdate = await ProductInfo.updateMany({ idapp }, {
|
||||||
$set: {
|
$set: {
|
||||||
totaleVenduti: 0,
|
totVen: 0,
|
||||||
venditeLastM: 0,
|
vLastM: 0,
|
||||||
venditeLast6M: 0,
|
vLast6M: 0,
|
||||||
venditeLastY: 0,
|
vLastY: 0,
|
||||||
venditeLast2Y: 0,
|
vLast2Y: 0,
|
||||||
rank3M: 0,
|
rank3M: 0,
|
||||||
rank6M: 0,
|
rank6M: 0,
|
||||||
rank1Y: 0,
|
rank1Y: 0,
|
||||||
@@ -876,20 +881,20 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
// id_wp: product._id,
|
// id_wp: product._id,
|
||||||
|
|
||||||
// name: product.title,
|
// name: product.title,
|
||||||
totaleVenduti: product.totaleVenduti || 0,
|
totVen: product.totVen || 0,
|
||||||
venditeLastM: product.venditeLastM || 0,
|
vLastM: product.vLastM || 0,
|
||||||
venditeLast6M: product.venditeLast6M || 0,
|
vLast6M: product.vLast6M || 0,
|
||||||
venditeLastY: product.venditeLastY || 0,
|
vLastY: product.vLastY || 0,
|
||||||
venditeLast2Y: product.venditeLast2Y || 0,
|
vLast2Y: product.vLast2Y || 0,
|
||||||
rank3M: product.rank3M || 0,
|
rank3M: product.rank3M || 0,
|
||||||
rank6M: product.rank6M || 0,
|
rank6M: product.rank6M || 0,
|
||||||
rank1Y: product.rank1Y || 0,
|
rank1Y: product.rank1Y || 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (product.DataPubblicazione) {
|
if (product.DataPubblicazione) {
|
||||||
productInfo.date_publishing = new Date(product.DataPubblicazione);
|
productInfo.date_pub = new Date(product.DataPubblicazione);
|
||||||
// convert data to timestamp
|
// convert data to timestamp
|
||||||
productInfo.date_publishing_ts = productInfo.date_publishing.getTime();
|
productInfo.date_pub_ts = productInfo.date_pub.getTime();
|
||||||
}
|
}
|
||||||
if (product.dataUltimoOrdine) {
|
if (product.dataUltimoOrdine) {
|
||||||
productInfo.dataUltimoOrdine = new Date(product.dataUltimoOrdine);
|
productInfo.dataUltimoOrdine = new Date(product.dataUltimoOrdine);
|
||||||
@@ -897,10 +902,10 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
// Update ProductInfo
|
// 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) {
|
if (risrecInfo) {
|
||||||
imported++;
|
imported++;
|
||||||
if (imported % 10 === 0)
|
if (imported % 50 === 0)
|
||||||
console.log('Importati... ', imported + '/' + numprod);
|
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 });
|
let risrec = await Importamacro.findOneAndUpdate(queryprod, { $set: recmacro }, { new: true, upsert: true, strict: false });
|
||||||
if (risrec) {
|
if (risrec) {
|
||||||
imported++;
|
imported++;
|
||||||
if (imported % 10 === 0)
|
if (imported % 50 === 0)
|
||||||
console.log('Importati su dir Temporanea ', imported);
|
console.log('Importati su dir Temporanea ', imported);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1034,7 +1039,7 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
let versione = 0;
|
let versione = 0;
|
||||||
|
|
||||||
if (indprod % 10 === 0)
|
if (indprod % 50 === 0)
|
||||||
console.log(indprod + '/' + numprod);
|
console.log(indprod + '/' + numprod);
|
||||||
|
|
||||||
|
|
||||||
@@ -1070,9 +1075,9 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
/*if (product.Data) {
|
/*if (product.Data) {
|
||||||
productInfo.date_publishing = new Date(product.Data * 1000);
|
productInfo.date_pub = new Date(product.Data * 1000);
|
||||||
// convert data to timestamp
|
// 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$/, "");
|
productInfo.name = productInfo.name.replace(/ - Usato$| - Nuovo$| - Epub$| - Ebook$| - Mobi$| - DVD$| - Streaming$| - Download$/, "");
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const { Reaction } = require('../models/reaction');
|
|||||||
|
|
||||||
const globalTables = require('../tools/globalTables');
|
const globalTables = require('../tools/globalTables');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
|
|
||||||
router.post('/getlist', authenticate_noerror, async function (req, res, next) {
|
router.post('/getlist', authenticate_noerror, async function (req, res, next) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const Subscription = require('../../models/subscribers');
|
|||||||
const { Graduatoria } = require('../../models/graduatoria');
|
const { Graduatoria } = require('../../models/graduatoria');
|
||||||
const { User } = require('../../models/user');
|
const { User } = require('../../models/user');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const tools = require('../../tools/general');
|
const tools = require('../../tools/general');
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const { authenticate } = require('../middleware/authenticate');
|
|||||||
|
|
||||||
const { Booking } = require('../models/booking');
|
const { Booking } = require('../models/booking');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const sendemail = require('../sendemail');
|
const sendemail = require('../sendemail');
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ router.post('/', authenticate, (req, res) => {
|
|||||||
} else {
|
} else {
|
||||||
// save to database a new record
|
// save to database a new record
|
||||||
tools.mylog('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) => {
|
return booking.save().then((writeresult) => {
|
||||||
let idobj = writeresult._id;
|
let idobj = writeresult._id;
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ router.delete('/:id/:notify/:idapp', authenticate, (req, res) => {
|
|||||||
//
|
//
|
||||||
// // tools.mylog('GET BOOKINGS : ', req.params);
|
// // tools.mylog('GET BOOKINGS : ', req.params);
|
||||||
//
|
//
|
||||||
// if (!ObjectID.isValid(userId)) {
|
// if (!ObjectId.isValid(userId)) {
|
||||||
// return res.status(404).send();
|
// return res.status(404).send();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const Order = require('../models/order');
|
|||||||
const Variant = require('../models/variant');
|
const Variant = require('../models/variant');
|
||||||
const { User } = require('../models/user');
|
const { User } = require('../models/user');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
/*const Department = require('../models/Department')
|
/*const Department = require('../models/Department')
|
||||||
const Category = require('../models/Category')
|
const Category = require('../models/Category')
|
||||||
@@ -442,7 +442,7 @@ router.post('/:userId/gestord', authenticate, async function (req, res, next) {
|
|||||||
$match: {
|
$match: {
|
||||||
idGasordine: {
|
idGasordine: {
|
||||||
$type: "objectId", // Checks if the field is of type ObjectId
|
$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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const { Account } = require('../models/account');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
async function getCircuitRecAdminsInfo(idapp, data) {
|
async function getCircuitRecAdminsInfo(idapp, data) {
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const Subscription = require('../models/subscribers');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const { City } = require('../models/city');
|
const { City } = require('../models/city');
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const telegrambot = require('../telegram/telegrambot');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
router.post('/', authenticate, async (req, res) => {
|
router.post('/', authenticate, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ const sharp = require('sharp');
|
|||||||
const { authenticate, authenticate_noerror } = require(
|
const { authenticate, authenticate_noerror } = require(
|
||||||
'../middleware/authenticate');
|
'../middleware/authenticate');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// const {ListaIngresso} = require('../models/listaingresso');
|
// const {ListaIngresso} = require('../models/listaingresso');
|
||||||
const { Graduatoria } = require('../models/graduatoria');
|
const { Graduatoria } = require('../models/graduatoria');
|
||||||
|
|
||||||
@@ -418,8 +419,8 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined || mytablerec._id === '0')) {
|
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined || mytablerec._id === '0')) {
|
||||||
mytablerec._id = new ObjectID();
|
mytablerec._id = new ObjectId();
|
||||||
mydata._id = new ObjectID();
|
mydata._id = new ObjectId();
|
||||||
mytablerec.isNew = true;
|
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
|
const existingRecord = await table.findOne({ idapp: appId, _id: record._id }); // Assumendo che `record` ha un ID
|
||||||
if (existingRecord) {
|
if (existingRecord) {
|
||||||
|
if (newIdPage && record.idPage) {
|
||||||
|
record.idPage = newIdPage;
|
||||||
|
}
|
||||||
const modif = await table.updateOne({ _id: record._id }, { $set: { ...record, idapp: appId } });
|
const modif = await table.updateOne({ _id: record._id }, { $set: { ...record, idapp: appId } });
|
||||||
wasModified = modif.nModified > 0;
|
wasModified = modif.nModified > 0;
|
||||||
} else {
|
} 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,
|
...record,
|
||||||
idapp: appId,
|
idapp: appId,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
const ris = await table.create(newrec);
|
||||||
wasModified = !!ris;
|
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) {
|
async function importPage(req, idapp, jsonString) {
|
||||||
try {
|
try {
|
||||||
|
console.log('INIZIO importPage');
|
||||||
|
|
||||||
// Parsing dei dati JSON
|
// Parsing dei dati JSON
|
||||||
const myexp = JSON.parse(jsonString);
|
const myexp = JSON.parse(jsonString);
|
||||||
|
|
||||||
@@ -939,12 +977,15 @@ async function importPage(req, idapp, jsonString) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let totalImportedRecords = 0;
|
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) {
|
for (const key in myexp) {
|
||||||
if (myexp.hasOwnProperty(key)) {
|
if (myexp.hasOwnProperty(key)) {
|
||||||
|
let ImportedRecordstemp = 0;
|
||||||
const tableName = key;
|
const tableName = key;
|
||||||
|
|
||||||
// Verifica se la tabella esiste
|
// Verifica se la tabella esiste
|
||||||
@@ -954,24 +995,61 @@ async function importPage(req, idapp, jsonString) {
|
|||||||
if (tableName === 'mypages') {
|
if (tableName === 'mypages') {
|
||||||
if (User.isEditor(req.user.perm)) {
|
if (User.isEditor(req.user.perm)) {
|
||||||
for (const page of myexp.mypages) {
|
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;
|
||||||
|
|
||||||
} else if (tableName === 'myelems') {
|
}
|
||||||
|
if (ImportedRecordstemp > 0)
|
||||||
|
importCounts.push({ tableName, count: ImportedRecordstemp });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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)) {
|
if (User.isEditor(req.user.perm)) {
|
||||||
for (const elem of myexp.myelems) {
|
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') {
|
} else if (tableName === 'myusers') {
|
||||||
if (User.isManager(req.user.perm)) {
|
if (User.isManager(req.user.perm)) {
|
||||||
for (const user of myexp.myusers) {
|
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}`);
|
console.log(`Importazione completata con successo. Totale record importati: ${totalImportedRecords}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { imported: totalImportedRecords };
|
return { imported: totalImportedRecords, importCounts };
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Errore durante l\'importazione:', 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) {
|
if (req.user) {
|
||||||
|
|
||||||
const userId = req.user._id;
|
const userId = req.user._id;
|
||||||
if (!ObjectID.isValid(userId)) {
|
if (!ObjectId.isValid(userId)) {
|
||||||
return res.status(404).send();
|
return res.status(404).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const express = require('express');
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
const IscrittiArcadei = require('../models/iscrittiArcadei');
|
const IscrittiArcadei = require('../models/iscrittiArcadei');
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const sendemail = require('../sendemail');
|
const sendemail = require('../sendemail');
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const express = require('express');
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
const IscrittiConacreis = require('../models/iscrittiConacreis');
|
const IscrittiConacreis = require('../models/iscrittiConacreis');
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const sendemail = require('../sendemail');
|
const sendemail = require('../sendemail');
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const {authenticate} = require('../middleware/authenticate');
|
|||||||
|
|
||||||
const {MyEvent} = require('../models/myevent');
|
const {MyEvent} = require('../models/myevent');
|
||||||
|
|
||||||
const {ObjectID} = require('mongodb');
|
const {ObjectId} = require('mongodb');
|
||||||
|
|
||||||
const sendemail = require('../sendemail');
|
const sendemail = require('../sendemail');
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ router.post('/', authenticate, (req, res) => {
|
|||||||
} else {
|
} else {
|
||||||
// save to database a new record
|
// save to database a new record
|
||||||
tools.mylog('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) => {
|
return myevent.save().then((writeresult) => {
|
||||||
let idobj = writeresult._id;
|
let idobj = writeresult._id;
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ router.get('/:userId/:idapp/:sall', authenticate, (req, res) => {
|
|||||||
|
|
||||||
// tools.mylog('GET myeventS : ', req.params);
|
// tools.mylog('GET myeventS : ', req.params);
|
||||||
|
|
||||||
if (!ObjectID.isValid(userId)) {
|
if (!ObjectId.isValid(userId)) {
|
||||||
return res.status(404).send();
|
return res.status(404).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const { Reaction } = require('../models/reaction');
|
|||||||
|
|
||||||
const globalTables = require('../tools/globalTables');
|
const globalTables = require('../tools/globalTables');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
//GET orders
|
//GET orders
|
||||||
router.post('/page', authenticate_noerror, function (req, res, next) {
|
router.post('/page', authenticate_noerror, function (req, res, next) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const _ = require('lodash');
|
|||||||
const {MyGood} = require('../models/mygood');
|
const {MyGood} = require('../models/mygood');
|
||||||
var {User} = require('../models/user');
|
var {User} = require('../models/user');
|
||||||
|
|
||||||
const {ObjectID} = require('mongodb');
|
const {ObjectId} = require('mongodb');
|
||||||
|
|
||||||
//GET orders
|
//GET orders
|
||||||
router.post('/page', authenticate, function(req, res, next) {
|
router.post('/page', authenticate, function(req, res, next) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const { MyGroup } = require('../models/mygroup');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
async function getGroupRecAdminsInfo(idapp, data) {
|
async function getGroupRecAdminsInfo(idapp, data) {
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const _ = require('lodash');
|
|||||||
const {MySkill} = require('../models/myskill');
|
const {MySkill} = require('../models/myskill');
|
||||||
var {User} = require('../models/user');
|
var {User} = require('../models/user');
|
||||||
|
|
||||||
const {ObjectID} = require('mongodb');
|
const {ObjectId} = require('mongodb');
|
||||||
|
|
||||||
//GET orders
|
//GET orders
|
||||||
router.post('/page', authenticate, function(req, res, next) {
|
router.post('/page', authenticate, function(req, res, next) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const Subscription = require('../models/subscribers');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const Product = require('../models/product');
|
const Product = require('../models/product');
|
||||||
const Order = require('../models/order');
|
const Order = require('../models/order');
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const { User } = require('../models/user');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
|
|
||||||
router.post('/', authenticate, (req, res) => {
|
router.post('/', authenticate, (req, res) => {
|
||||||
@@ -83,7 +83,7 @@ router.patch('/:id', authenticate, (req, res) => {
|
|||||||
|
|
||||||
tools.mylogshow('PATCH PROJECT: ', id);
|
tools.mylogshow('PATCH PROJECT: ', id);
|
||||||
|
|
||||||
if (!ObjectID.isValid(id)) {
|
if (!ObjectId.isValid(id)) {
|
||||||
tools.mylog('ERROR: id not VALID', id);
|
tools.mylog('ERROR: id not VALID', id);
|
||||||
return res.status(404).send();
|
return res.status(404).send();
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ router.get('/:userId', authenticate, (req, res) => {
|
|||||||
const idapp = req.query.idapp;
|
const idapp = req.query.idapp;
|
||||||
|
|
||||||
|
|
||||||
if (!ObjectID.isValid(userId)) {
|
if (!ObjectId.isValid(userId)) {
|
||||||
return res.status(404).send();
|
return res.status(404).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ router.delete('/:id', authenticate, (req, res) => {
|
|||||||
|
|
||||||
const hide = true;
|
const hide = true;
|
||||||
|
|
||||||
if (!ObjectID.isValid(id)) {
|
if (!ObjectId.isValid(id)) {
|
||||||
return res.status(404).send();
|
return res.status(404).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const { Reaction } = require('../models/reaction');
|
|||||||
const { User } = require('../models/user');
|
const { User } = require('../models/user');
|
||||||
|
|
||||||
const Hours = require('../models/hours');
|
const Hours = require('../models/hours');
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const sendemail = require('../sendemail');
|
const sendemail = require('../sendemail');
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const Hours = require('../models/hours');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
router.post('/load', authenticate, async (req, res) => {
|
router.post('/load', authenticate, async (req, res) => {
|
||||||
let date_start = req.body.date_start;
|
let date_start = req.body.date_start;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const { SendMsg } = require('../models/sendmsg');
|
|||||||
|
|
||||||
const { SendNotif } = require('../models/sendnotif');
|
const { SendNotif } = require('../models/sendnotif');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const sendemail = require('../sendemail');
|
const sendemail = require('../sendemail');
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ router.post('/', authenticate, (req, res) => {
|
|||||||
|
|
||||||
// console.log('fieldtochange', fieldtochange);
|
// console.log('fieldtochange', fieldtochange);
|
||||||
|
|
||||||
myrecmsg._id = new ObjectID();
|
myrecmsg._id = new ObjectId();
|
||||||
return myrecmsg.save()
|
return myrecmsg.save()
|
||||||
.then((writeresult) => {
|
.then((writeresult) => {
|
||||||
let idobj = writeresult._id;
|
let idobj = writeresult._id;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const mongoose = require('mongoose').set('debug', false)
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
// const { ExtraList } = require('../models/extralist');
|
// const { ExtraList } = require('../models/extralist');
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const { Settings } = require('../models/settings');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
|
|
||||||
router.get('/', (req, res) => {
|
router.get('/', (req, res) => {
|
||||||
@@ -39,7 +39,7 @@ router.get('/', (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const myrec = new Todo(todo);
|
const myrec = new Todo(todo);
|
||||||
myrec._id = new ObjectID();
|
myrec._id = new ObjectId();
|
||||||
|
|
||||||
const TodoOne = myrec.save().then((ris, err) => {
|
const TodoOne = myrec.save().then((ris, err) => {
|
||||||
console.log('Err:', err);
|
console.log('Err:', err);
|
||||||
@@ -49,7 +49,7 @@ router.get('/', (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
const newrec = new Settings({ key: 'chiave1' });
|
const newrec = new Settings({ key: 'chiave1' });
|
||||||
newrec._id = new ObjectID();
|
newrec._id = new ObjectId();
|
||||||
newrec.idapp = '8';
|
newrec.idapp = '8';
|
||||||
|
|
||||||
newrec.save((err, rec) => {
|
newrec.save((err, rec) => {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const Hours = require('../models/hours');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
|
|
||||||
router.post('/', authenticate, async (req, res) => {
|
router.post('/', authenticate, async (req, res) => {
|
||||||
@@ -93,7 +93,7 @@ router.patch('/:id', authenticate, (req, res) => {
|
|||||||
|
|
||||||
// tools.mylogshow('PATCH TODO: ', id);
|
// tools.mylogshow('PATCH TODO: ', id);
|
||||||
|
|
||||||
if (!ObjectID.isValid(id)) {
|
if (!ObjectId.isValid(id)) {
|
||||||
tools.mylog('ERROR: id not VALID', id);
|
tools.mylog('ERROR: id not VALID', id);
|
||||||
return res.status(404).send();
|
return res.status(404).send();
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ router.get('/:userId', authenticate, (req, res) => {
|
|||||||
|
|
||||||
// tools.mylog('GET TODOS : ', req.params);
|
// tools.mylog('GET TODOS : ', req.params);
|
||||||
|
|
||||||
if (!ObjectID.isValid(userId)) {
|
if (!ObjectId.isValid(userId)) {
|
||||||
return res.status(404).send();
|
return res.status(404).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ router.get('/:userId', authenticate, (req, res) => {
|
|||||||
router.get('/test', (req, res) => {
|
router.get('/test', (req, res) => {
|
||||||
|
|
||||||
const todo = {
|
const todo = {
|
||||||
_id: new ObjectID(),
|
_id: new ObjectId(),
|
||||||
// category: "personal",
|
// category: "personal",
|
||||||
statustodo: 0,
|
statustodo: 0,
|
||||||
completed_at: new Date(),
|
completed_at: new Date(),
|
||||||
@@ -239,7 +239,7 @@ router.delete('/:id', authenticate, (req, res) => {
|
|||||||
|
|
||||||
let hide = true;
|
let hide = true;
|
||||||
|
|
||||||
if (!ObjectID.isValid(id)) {
|
if (!ObjectId.isValid(id)) {
|
||||||
return res.status(404).send();
|
return res.status(404).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const { MyGroup } = require('../models/mygroup');
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
async function getGroupRecAdminsInfo(idapp, data) {
|
async function getGroupRecAdminsInfo(idapp, data) {
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const Hours = require('../models/hours');
|
|||||||
//const { ListaIngresso } = require('../models/listaingresso');
|
//const { ListaIngresso } = require('../models/listaingresso');
|
||||||
//const { Graduatoria } = require('../models/graduatoria');
|
//const { Graduatoria } = require('../models/graduatoria');
|
||||||
// const { ExtraList } = require('../models/extralist');
|
// const { ExtraList } = require('../models/extralist');
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const sendemail = require('../sendemail');
|
const sendemail = require('../sendemail');
|
||||||
|
|
||||||
@@ -1338,7 +1338,7 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
|||||||
|
|
||||||
for (let ind = 0; ind < 100; ind++) {
|
for (let ind = 0; ind < 100; ind++) {
|
||||||
let myuser = new User();
|
let myuser = new User();
|
||||||
myuser._id = new ObjectID();
|
myuser._id = new ObjectId();
|
||||||
myuser.index = last + ind + 1;
|
myuser.index = last + ind + 1;
|
||||||
myuser.idapp = idapp;
|
myuser.idapp = idapp;
|
||||||
myuser.password = '$2a$12$DEaX1h5saTUVC43f7kubyOAlah1xHDgqQTfSIux0.RFDT9WGbyCaG';
|
myuser.password = '$2a$12$DEaX1h5saTUVC43f7kubyOAlah1xHDgqQTfSIux0.RFDT9WGbyCaG';
|
||||||
@@ -1552,23 +1552,34 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
|||||||
|
|
||||||
} else if (mydata.dbop === 'dropProducts') {
|
} else if (mydata.dbop === 'dropProducts') {
|
||||||
|
|
||||||
await Product.collection.drop();
|
if (idapp) {
|
||||||
ris = await ProductInfo.collection.drop();
|
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') {
|
} else if (mydata.dbop === 'dropCatProd') {
|
||||||
|
|
||||||
await CatProd.collection.drop();
|
const deleteCatProd = await CatProd.deleteMany({ idapp });
|
||||||
|
|
||||||
} else if (mydata.dbop === 'dropSubCatProd') {
|
} else if (mydata.dbop === 'dropSubCatProd') {
|
||||||
|
|
||||||
await SubCatProd.collection.drop();
|
const deleteSubCatProd = await SubCatProd.deleteMany({ idapp });
|
||||||
|
|
||||||
} else if (mydata.dbop === 'dropAllOrders') {
|
} else if (mydata.dbop === 'dropAllOrders') {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ris = Order.collection.drop();
|
const deleteOrder = await Order.deleteMany({ idapp });
|
||||||
ris = OrdersCart.collection.drop();
|
const deleteOrdersCart = await OrdersCart.deleteMany({ idapp });
|
||||||
ris = Cart.collection.drop();
|
const deleteCart = await Cart.deleteMany({ idapp });
|
||||||
|
|
||||||
|
ris = deleteCart;
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Err:', e);
|
console.error('Err:', e);
|
||||||
}
|
}
|
||||||
@@ -1601,7 +1612,7 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
|||||||
|
|
||||||
} else if (mydata.dbop === 'dropAllCarts') {
|
} else if (mydata.dbop === 'dropAllCarts') {
|
||||||
|
|
||||||
ris = Cart.collection.drop();
|
ris = await Cart.deleteMany({ idapp });
|
||||||
|
|
||||||
} else if (mydata.dbop === 'RewriteCitiesTable') {
|
} else if (mydata.dbop === 'RewriteCitiesTable') {
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const { decode } = require('entities');
|
|||||||
|
|
||||||
const i18n = require('i18n');
|
const i18n = require('i18n');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
const { Settings } = require('./models/settings');
|
const { Settings } = require('./models/settings');
|
||||||
const { TemplEmail } = require('./models/templemail');
|
const { TemplEmail } = require('./models/templemail');
|
||||||
const { Discipline } = require('./models/discipline');
|
const { Discipline } = require('./models/discipline');
|
||||||
@@ -574,7 +574,7 @@ module.exports = {
|
|||||||
email: mylocalsconf.emailto,
|
email: mylocalsconf.emailto,
|
||||||
hash,
|
hash,
|
||||||
});
|
});
|
||||||
myperson._id = new ObjectID();
|
myperson._id = new ObjectId();
|
||||||
} else {
|
} else {
|
||||||
myperson.name = mylocalsconf.name;
|
myperson.name = mylocalsconf.name;
|
||||||
myperson.surname = mylocalsconf.surname;
|
myperson.surname = mylocalsconf.surname;
|
||||||
@@ -937,7 +937,7 @@ module.exports = {
|
|||||||
const updateml = await User.findOneAndUpdate({
|
const updateml = await User.findOneAndUpdate({
|
||||||
idapp,
|
idapp,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
}, { $set: { lastid_newstosent: ObjectID(id_newstosent) } }, { new: false });
|
}, { $set: { lastid_newstosent: ObjectId(id_newstosent) } }, { new: false });
|
||||||
|
|
||||||
//Delay for send email...
|
//Delay for send email...
|
||||||
await tools.snooze(secpause);
|
await tools.snooze(secpause);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ var mongoose = require('mongoose').set('debug', false);
|
|||||||
mongoose.set('debug', false);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
const { CfgServer } = require('./models/cfgserver');
|
const { CfgServer } = require('./models/cfgserver');
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const populate = require('./populate/populate');
|
const populate = require('./populate/populate');
|
||||||
const { Circuit } = require('./models/circuit');
|
const { Circuit } = require('./models/circuit');
|
||||||
@@ -338,7 +338,7 @@ async function mystart() {
|
|||||||
function populateDBadmin() {
|
function populateDBadmin() {
|
||||||
const cfgserv = [
|
const cfgserv = [
|
||||||
{
|
{
|
||||||
_id: new ObjectID(),
|
_id: new ObjectId(),
|
||||||
idapp: '9',
|
idapp: '9',
|
||||||
chiave: 'vers',
|
chiave: 'vers',
|
||||||
userId: 'ALL',
|
userId: 'ALL',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const {ObjectID} = require('mongodb');
|
const {ObjectId} = require('mongodb');
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
|
|
||||||
const {Todo} = require('../../models/todo');
|
const {Todo} = require('../../models/todo');
|
||||||
@@ -10,9 +10,9 @@ const tools = require('../../tools/general');
|
|||||||
|
|
||||||
let myuserIdOne = '';
|
let myuserIdOne = '';
|
||||||
|
|
||||||
const userOneId = new ObjectID();
|
const userOneId = new ObjectId();
|
||||||
const userTwoId = new ObjectID();
|
const userTwoId = new ObjectId();
|
||||||
// const userThreeId = new ObjectID();
|
// const userThreeId = new ObjectId();
|
||||||
|
|
||||||
// let mypwdcrypt = bcrypt.hash(mypwdchiaro, bcrypt.genSaltSync(12))
|
// let mypwdcrypt = bcrypt.hash(mypwdchiaro, bcrypt.genSaltSync(12))
|
||||||
// .then((hashedPassword) => {
|
// .then((hashedPassword) => {
|
||||||
@@ -82,11 +82,11 @@ const userjson = JSON.stringify(users[0]);
|
|||||||
|
|
||||||
// console.log('userjson=', userjson)
|
// console.log('userjson=', userjson)
|
||||||
|
|
||||||
const mynewID = new ObjectID();
|
const mynewID = new ObjectId();
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', false)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
var ObjectId = mongoose.Types.ObjectId;
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const todos = [
|
const todos = [
|
||||||
{
|
{
|
||||||
@@ -106,7 +106,7 @@ const todos = [
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
userId: users[0]._id,
|
userId: users[0]._id,
|
||||||
}, {
|
}, {
|
||||||
_id: new ObjectID(),
|
_id: new ObjectId(),
|
||||||
category: ObjectId(mynewID),
|
category: ObjectId(mynewID),
|
||||||
statustodo: 0,
|
statustodo: 0,
|
||||||
completed_at: new Date(),
|
completed_at: new Date(),
|
||||||
@@ -121,7 +121,7 @@ const todos = [
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
userId: users[1]._id,
|
userId: users[1]._id,
|
||||||
}, {
|
}, {
|
||||||
_id: new ObjectID(),
|
_id: new ObjectId(),
|
||||||
category: ObjectId(mynewID),
|
category: ObjectId(mynewID),
|
||||||
statustodo: 0,
|
statustodo: 0,
|
||||||
completed_at: new Date(),
|
completed_at: new Date(),
|
||||||
@@ -136,7 +136,7 @@ const todos = [
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
userId: users[2]._id,
|
userId: users[2]._id,
|
||||||
}, { // RECORD CHE VERRA' UTILIZZATO PER AGGIUNGERE UN NUOVO TASK
|
}, { // RECORD CHE VERRA' UTILIZZATO PER AGGIUNGERE UN NUOVO TASK
|
||||||
_id: new ObjectID(),
|
_id: new ObjectId(),
|
||||||
category: ObjectId(mynewID),
|
category: ObjectId(mynewID),
|
||||||
statustodo: 0,
|
statustodo: 0,
|
||||||
completed_at: new Date(),
|
completed_at: new Date(),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const expect = require('expect');
|
const expect = require('expect');
|
||||||
const request = require('supertest');
|
const request = require('supertest');
|
||||||
const {ObjectID} = require('mongodb');
|
const {ObjectId} = require('mongodb');
|
||||||
|
|
||||||
const {app} = require('../server');
|
const {app} = require('../server');
|
||||||
const {Todo} = require('../models/todo');
|
const {Todo} = require('../models/todo');
|
||||||
@@ -317,7 +317,7 @@ if (testsingolo) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('FORBIDDEN ! should return [] if user not found', (done) => {
|
it('FORBIDDEN ! should return [] if user not found', (done) => {
|
||||||
var hexId = new ObjectID().toHexString();
|
var hexId = new ObjectId().toHexString();
|
||||||
|
|
||||||
request(app).
|
request(app).
|
||||||
get(`/todos/${hexId}`).
|
get(`/todos/${hexId}`).
|
||||||
@@ -363,7 +363,7 @@ if (testsingolo) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return 404 if todo not found', (done) => {
|
it('should return 404 if todo not found', (done) => {
|
||||||
var hexId = new ObjectID().toHexString();
|
var hexId = new ObjectId().toHexString();
|
||||||
|
|
||||||
request(app).
|
request(app).
|
||||||
delete(`/todos/${hexId}`).
|
delete(`/todos/${hexId}`).
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const axios = require('axios');
|
|||||||
const CryptoJS = require('crypto-js');
|
const CryptoJS = require('crypto-js');
|
||||||
const Url = require('url-parse');
|
const Url = require('url-parse');
|
||||||
|
|
||||||
const { ObjectID, ObjectId } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const shared_consts = require('./shared_nodejs');
|
const shared_consts = require('./shared_nodejs');
|
||||||
|
|
||||||
@@ -845,7 +845,7 @@ module.exports = {
|
|||||||
CloneRecordToNew(src) {
|
CloneRecordToNew(src) {
|
||||||
const myrec = Object.assign({}, src);
|
const myrec = Object.assign({}, src);
|
||||||
delete myrec._doc['_id'];
|
delete myrec._doc['_id'];
|
||||||
myrec._id = new ObjectID();
|
myrec._id = new ObjectId();
|
||||||
|
|
||||||
return myrec._doc;
|
return myrec._doc;
|
||||||
},
|
},
|
||||||
@@ -2646,6 +2646,8 @@ module.exports = {
|
|||||||
filtriadded.push({ 'profile.teleg_id_old': { $gt: 1 } });
|
filtriadded.push({ 'profile.teleg_id_old': { $gt: 1 } });
|
||||||
if (params.filterand.includes(shared_consts.FILTER_USER_PROVINCE))
|
if (params.filterand.includes(shared_consts.FILTER_USER_PROVINCE))
|
||||||
filtriadded.push({ 'profile.resid_province': { $exists: true } });
|
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))
|
if (params.filterand.includes(shared_consts.FILTER_ATTIVI))
|
||||||
filtriadded.push({
|
filtriadded.push({
|
||||||
$or: [
|
$or: [
|
||||||
@@ -2715,10 +2717,10 @@ module.exports = {
|
|||||||
let condition = {};
|
let condition = {};
|
||||||
for (const myfilter of params.filtercustom) {
|
for (const myfilter of params.filtercustom) {
|
||||||
if (myfilter['userId']) {
|
if (myfilter['userId']) {
|
||||||
myfilter['userId'] = ObjectID(myfilter['userId']);
|
myfilter['userId'] = ObjectId(myfilter['userId']);
|
||||||
}
|
}
|
||||||
if (myfilter['_idOBJ']) {
|
if (myfilter['_idOBJ']) {
|
||||||
filtriadded.push({ _id: ObjectID(myfilter['_idOBJ']) });
|
filtriadded.push({ _id: ObjectId(myfilter['_idOBJ']) });
|
||||||
} else if (myfilter['dateTimeStart']) {
|
} else if (myfilter['dateTimeStart']) {
|
||||||
const gte = myfilter['dateTimeStart'].$gte;
|
const gte = myfilter['dateTimeStart'].$gte;
|
||||||
const lte = myfilter['dateTimeStart'].$lte;
|
const lte = myfilter['dateTimeStart'].$lte;
|
||||||
@@ -3398,7 +3400,7 @@ module.exports = {
|
|||||||
|
|
||||||
for (let ind = 0; ind < arrrec.length; ind++) {
|
for (let ind = 0; ind < arrrec.length; ind++) {
|
||||||
let newrec = new mythistable(arrrec[ind]);
|
let newrec = new mythistable(arrrec[ind]);
|
||||||
newrec._id = new ObjectID();
|
newrec._id = new ObjectId();
|
||||||
newrec.idapp = idappdest;
|
newrec.idapp = idappdest;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ require('../config/config');
|
|||||||
|
|
||||||
require('../models/subscribers');
|
require('../models/subscribers');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectId } = require('mongodb');
|
||||||
|
|
||||||
const { User } = require('../models/user');
|
const { User } = require('../models/user');
|
||||||
const { MyGroup } = require('../models/mygroup');
|
const { MyGroup } = require('../models/mygroup');
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ module.exports = {
|
|||||||
FILTER_USER_SI_TELEGRAM_ID: 4194304,
|
FILTER_USER_SI_TELEGRAM_ID: 4194304,
|
||||||
FILTER_USER_WITHOUT_USERNAME_TELEGRAM: 8388608,
|
FILTER_USER_WITHOUT_USERNAME_TELEGRAM: 8388608,
|
||||||
FILTER_USER_PROVINCE: 16777216,
|
FILTER_USER_PROVINCE: 16777216,
|
||||||
|
FILTER_USER_SENZA_PROVINCE: 33554432,
|
||||||
|
|
||||||
OPTIONS_SEARCH_ONLY_FULL_WORDS: 1,
|
OPTIONS_SEARCH_ONLY_FULL_WORDS: 1,
|
||||||
OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2,
|
OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2,
|
||||||
@@ -245,7 +246,7 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||||
TABLES_CREATEDBY: ['mygroups', 'circuits', 'attivitas'],
|
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'],
|
TABLES_FIELDS_DESCR_AND_CITY_AND_USER: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.1.12
|
1.1.14
|
||||||
Reference in New Issue
Block a user