2019-10-05 20:01:56 +02:00
|
|
|
const mongoose = require('mongoose');
|
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
|
|
|
|
|
|
mongoose.Promise = global.Promise;
|
|
|
|
|
mongoose.level = "F";
|
|
|
|
|
|
|
|
|
|
const { ObjectID } = require('mongodb');
|
|
|
|
|
|
|
|
|
|
// Resolving error Unknown modifier: $pushAll
|
|
|
|
|
mongoose.plugin(schema => {
|
|
|
|
|
schema.options.usePushEach = true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const bookingSchema = new Schema({
|
|
|
|
|
idapp: {
|
|
|
|
|
type: Number,
|
|
|
|
|
},
|
|
|
|
|
userId: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
id_bookedevent: {
|
|
|
|
|
type: Number,
|
|
|
|
|
},
|
|
|
|
|
numpeople: {
|
|
|
|
|
type: Number,
|
|
|
|
|
},
|
|
|
|
|
infoevent: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
msgbooking: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
datebooked: {
|
|
|
|
|
type: Date,
|
|
|
|
|
},
|
2019-10-10 21:08:12 +02:00
|
|
|
modified: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
|
|
|
|
},
|
2019-10-05 20:01:56 +02:00
|
|
|
booked: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bookingSchema.statics.findAllByUserIdAndIdApp = function (userId, idapp) {
|
|
|
|
|
const Booking = this;
|
|
|
|
|
|
|
|
|
|
return Booking.find({userId, idapp, booked: true}, (err, arrbooked) => {
|
2019-10-10 21:08:12 +02:00
|
|
|
// console.log('ris Booking:', arrbooked);
|
2019-10-05 20:01:56 +02:00
|
|
|
return arrbooked
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Booking = mongoose.model('Booking', bookingSchema);
|
|
|
|
|
|
|
|
|
|
module.exports = { Booking };
|