Files
freeplanet_serverside/server/models/booking.js
Paolo Arena 8f69856c57 - Booking Event (with email to user and admin)
- Cancel Event (with email to user and admin)
- Store into mongodb
2019-10-05 20:01:56 +02:00

55 lines
971 B
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,
},
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 };