Skip to content

Instantly share code, notes, and snippets.

@shubham7298
Created October 24, 2020 14:09
Show Gist options
  • Save shubham7298/bf8384c3e70cdbb9dcfa209974336c41 to your computer and use it in GitHub Desktop.
Save shubham7298/bf8384c3e70cdbb9dcfa209974336c41 to your computer and use it in GitHub Desktop.
children schema in mongoose
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