Files
freeplanet_serverside/server/models/booking.js
2019-10-10 21:08:12 +02:00

59 lines
1.0 KiB
JavaScript

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,
},
modified: {
type: Boolean,
default: false
},
booked: {
type: Boolean,
},
});
bookingSchema.statics.findAllByUserIdAndIdApp = function (userId, idapp) {
const Booking = this;
return Booking.find({userId, idapp, booked: true}, (err, arrbooked) => {
// console.log('ris Booking:', arrbooked);
return arrbooked
});
};
var Booking = mongoose.model('Booking', bookingSchema);
module.exports = { Booking };