- Aggiornato tutti i pacchetti del server all'ultima versione. - passato mongoose da versione 5 a versione 6
53 lines
1.0 KiB
JavaScript
Executable File
53 lines
1.0 KiB
JavaScript
Executable File
const mongoose = require('mongoose').set('debug', false)
|
|
const Schema = mongoose.Schema;
|
|
|
|
mongoose.Promise = global.Promise;
|
|
mongoose.level = "F";
|
|
|
|
const tools = require('../tools/general');
|
|
const { ObjectId } = require('mongodb');
|
|
|
|
// Resolving error Unknown modifier: $pushAll
|
|
mongoose.plugin(schema => {
|
|
schema.options.usePushEach = true
|
|
});
|
|
|
|
const CfgServerSchema = new Schema({
|
|
chiave: {
|
|
type: String,
|
|
trim: true,
|
|
minlength: 1,
|
|
},
|
|
idapp: {
|
|
type: String,
|
|
},
|
|
userId: {
|
|
type: String,
|
|
},
|
|
valore: {
|
|
type: String,
|
|
},
|
|
});
|
|
|
|
CfgServerSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
|
|
|
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
|
|
|
|
};
|
|
|
|
CfgServerSchema.statics.findAllIdApp = async function(idapp) {
|
|
const myfind = { idapp };
|
|
|
|
return await CfgServer.find(myfind).lean();
|
|
};
|
|
|
|
const CfgServer = mongoose.model('CfgServer', CfgServerSchema);
|
|
|
|
CfgServer.createIndexes()
|
|
.then(() => { })
|
|
.catch((err) => { throw err; });
|
|
|
|
|
|
module.exports = {CfgServer};
|
|
|