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 };