nuova veste grafica: myskills, mygoods, mybachecas, myhosps,
- cambiato id (da numero a stringa)
This commit is contained in:
@@ -6,6 +6,8 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
@@ -80,7 +82,6 @@ const MyGoodSchema = new Schema({
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
@@ -89,18 +90,8 @@ const MyGoodSchema = new Schema({
|
||||
|
||||
MyGoodSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await MyGood.findOne().limit(1).sort({ _id: -1 });
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
else
|
||||
this._id = myrec._doc._id + 1;
|
||||
|
||||
} else {
|
||||
this._id = 1;
|
||||
}
|
||||
|
||||
this.date_created = new Date();
|
||||
if (!this.date_created)
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
@@ -145,37 +136,7 @@ MyGoodSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
lk_FF: '_id',
|
||||
lk_as: 'user',
|
||||
af_objId_tab: 'myId',
|
||||
lk_proj: {
|
||||
idGood: 1,
|
||||
idShipping: 1,
|
||||
MyGood: 1,
|
||||
idStatusGood: 1,
|
||||
idContribType: 1,
|
||||
'profile.username_telegram': 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
'profile.resid_province': 1,
|
||||
reported: 1,
|
||||
},
|
||||
lk_proj: this.getProject(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -188,22 +149,13 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
||||
const MyGood = this;
|
||||
|
||||
let myparsid = {
|
||||
$or: [
|
||||
{
|
||||
'_id': parseInt(idGood)
|
||||
},
|
||||
{
|
||||
'_id': idGood,
|
||||
}]
|
||||
'_id': idGood,
|
||||
};
|
||||
|
||||
const query = [
|
||||
let query = [
|
||||
{
|
||||
'$match': {
|
||||
'$and': [
|
||||
'$match':
|
||||
myparsid,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
'$match': {
|
||||
@@ -246,39 +198,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
'photos': 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
'profile.resid_province': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -304,39 +224,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
'profile.resid_province': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -363,39 +251,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
'profile.resid_province': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -421,39 +277,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
'profile.resid_province': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -478,41 +302,17 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYGOODS);
|
||||
|
||||
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
|
||||
query = [...query, ...objadd.query];
|
||||
|
||||
query = [...query,
|
||||
{
|
||||
'$project': {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
'profile.resid_province': 1,
|
||||
reported: 1,
|
||||
},
|
||||
},
|
||||
$project: this.getProject(objadd.proj),
|
||||
}
|
||||
];
|
||||
|
||||
return MyGood.aggregate(query).then((rec) => {
|
||||
@@ -527,6 +327,23 @@ MyGoodSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
|
||||
};
|
||||
|
||||
MyGoodSchema.statics.getProject = function () {
|
||||
let proj = {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
//**ADDFIELD_MYGOOD
|
||||
|
||||
};
|
||||
|
||||
const proj_add = shared_consts.getProjectForAll()
|
||||
|
||||
return Object.assign({}, proj, proj_add);
|
||||
|
||||
}
|
||||
|
||||
const MyGood = mongoose.model('MyGood', MyGoodSchema);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user