- fix: se salvavo un record 'settable' e non era completo con tutti i campi, andava a troncare gli altri precedentemente inseriti
- ordinamento Circuiti per stato e numiscritti e descr
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
],
|
||||
"settings": {
|
||||
"search.useIgnoreFiles": false,
|
||||
"search.useParentIgnoreFiles": false
|
||||
"search.useParentIgnoreFiles": false,
|
||||
"files.exclude": {
|
||||
"": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,9 +225,7 @@ CircuitSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, '');
|
||||
|
||||
return await Circuit.find(myfind, whatToShow, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
return await Circuit.find(myfind, whatToShow).sort({status: -1, numMembers: -1, name: 1});
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getFieldsForSearch = function () {
|
||||
@@ -372,14 +370,14 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}).lean();
|
||||
}).sort({status: -1, numMembers: -1, name: 1}).lean();
|
||||
|
||||
let listcircuits = await Circuit.find({
|
||||
idapp,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown).lean();
|
||||
}, whatToShow_Unknown).sort({status: -1, numMembers: -1, name: 1}).lean();
|
||||
|
||||
let asked_circuits = await Circuit.find({
|
||||
idapp,
|
||||
@@ -389,7 +387,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown).lean();
|
||||
}, whatToShow_Unknown).sort({status: -1}).lean();
|
||||
|
||||
let refused_circuits = await Circuit.find({
|
||||
idapp,
|
||||
@@ -399,7 +397,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown).lean();
|
||||
}, whatToShow_Unknown).sort({status: -1}).lean();
|
||||
|
||||
return {
|
||||
listcircuits,
|
||||
|
||||
@@ -366,6 +366,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
} else {
|
||||
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined)) {
|
||||
mytablerec._id = new ObjectID();
|
||||
mydata._id = new ObjectID();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,12 +402,31 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
|
||||
if (shared_consts.TABLES_UPDATE_LASTMODIFIED.includes(params.table)) {
|
||||
mytablerec.date_updated = new Date();
|
||||
mydata.date_updated = new Date();
|
||||
}
|
||||
|
||||
// console.log('mydata',mydata);
|
||||
// return await mytablerec.save().
|
||||
// then(async (rec) => {
|
||||
|
||||
return await mytablerec.save().
|
||||
then(async (rec) => {
|
||||
const myPromise = new Promise((resolve, reject) => {
|
||||
resolve(mytablerec._id && mytable.findById(mytablerec._id))
|
||||
});
|
||||
|
||||
return await myPromise
|
||||
.then(async (doupdate) => {
|
||||
if (doupdate)
|
||||
return mytable.updateOne({ _id: mytablerec._id }, mydata, { new: true })
|
||||
else
|
||||
return mytablerec.save()
|
||||
})
|
||||
.then(async (risult) => {
|
||||
let rec = null;
|
||||
if (risult && risult.ok === 1) {
|
||||
rec = await mytable.findById(mytablerec._id).lean();
|
||||
} else {
|
||||
rec = risult;
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_GETCOMPLETEREC.includes(params.table)) {
|
||||
return await mytablestrutt.getCompleteRecord(rec.idapp, rec._id);
|
||||
|
||||
Reference in New Issue
Block a user