- Booking Event (with email to user and admin)
- Cancel Event (with email to user and admin) - Store into mongodb
This commit is contained in:
54
server/models/booking.js
Normal file
54
server/models/booking.js
Normal file
@@ -0,0 +1,54 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user