Created
October 24, 2020 14:09
-
-
Save shubham7298/bf8384c3e70cdbb9dcfa209974336c41 to your computer and use it in GitHub Desktop.
children schema in mongoose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const Schema = mongoose.Schema, | |
model = mongoose.model.bind(mongoose), | |
ObjectId = mongoose.Schema.Types.ObjectId; | |
const slotSchema = new Schema ({ | |
slot_time: String, | |
slot_date: String, | |
created_at: Date | |
}); | |
const Slot = model('Slot', slotSchema); | |
const appointmentSchema = new Schema({ | |
id: ObjectId, | |
name: String, | |
email: String, | |
phone: Number, | |
slots:{type: ObjectId, ref: 'Slot'}, | |
created_at: Date | |
}); | |
const Appointment = model('Appointment', appointmentSchema); | |
module.exports = { | |
Appointment, Slot | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment