correzione numseen, numfav, ...: ora li ho aggiunti alle tabelle...
This commit is contained in:
@@ -6,6 +6,8 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const { Reaction } = require('./reaction');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
@@ -15,81 +17,84 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const MyHospSchema = new Schema({
|
||||
_id: {
|
||||
type: String,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
visibile: {
|
||||
type: Boolean
|
||||
},
|
||||
typeHosp: { // scambio casa / ospitalità
|
||||
type: Number,
|
||||
},
|
||||
numMaxPeopleHosp: {
|
||||
type: Number,
|
||||
},
|
||||
accomodation: [
|
||||
{
|
||||
type: { // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo) / culla
|
||||
type: Number,
|
||||
},
|
||||
location: { // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto
|
||||
type: Number,
|
||||
},
|
||||
num: {
|
||||
type: Number,
|
||||
},
|
||||
}],
|
||||
preferences: [ // Accetto bambini, Accetto cani, Accetto gatti, E' consentito fumare in casa, Accessibile con sedia a rotelle
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
...{
|
||||
_id: {
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
visibile: {
|
||||
type: Boolean
|
||||
},
|
||||
typeHosp: { // scambio casa / ospitalità
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
link_maplocation: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
numMaxPeopleHosp: {
|
||||
type: Number,
|
||||
},
|
||||
accomodation: [
|
||||
{
|
||||
type: { // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo) / culla
|
||||
type: Number,
|
||||
},
|
||||
location: { // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto
|
||||
type: Number,
|
||||
},
|
||||
num: {
|
||||
type: Number,
|
||||
},
|
||||
}],
|
||||
preferences: [ // Accetto bambini, Accetto cani, Accetto gatti, E' consentito fumare in casa, Accessibile con sedia a rotelle
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
link_maplocation: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions()
|
||||
});
|
||||
|
||||
MyHospSchema.pre('save', async function (next) {
|
||||
@@ -154,7 +159,7 @@ MyHospSchema.statics.getMyRecById = function (idapp, id) {
|
||||
let query = [
|
||||
{
|
||||
'$match':
|
||||
myparsid,
|
||||
myparsid,
|
||||
},
|
||||
{
|
||||
'$sort': {
|
||||
@@ -306,7 +311,7 @@ MyHospSchema.statics.getMyRecById = function (idapp, id) {
|
||||
$project: this.getProject(objadd.proj),
|
||||
};
|
||||
|
||||
query = [...query, {...toadd}];
|
||||
query = [...query, { ...toadd }];
|
||||
|
||||
return MyHosp.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
@@ -337,7 +342,7 @@ MyHospSchema.statics.getProject = function () {
|
||||
const proj_add = shared_consts.getProjectForAll()
|
||||
|
||||
return Object.assign({}, proj, proj_add);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user