-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.js
More file actions
31 lines (26 loc) · 885 Bytes
/
models.js
File metadata and controls
31 lines (26 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const mongoose = require('mongoose');
const { Schema } = mongoose;
const User = mongoose.model('User', new Schema({
name: String,
email: String,
password: String,
}));
const Resource = mongoose.model('Resource', new Schema({
resourceID: Schema.Types.ObjectId,
identifier: String,
category: String,
bookings: [{ type: Schema.Types.ObjectId, ref: 'Booking' }],
tags: Array,
description: String,
availableDays: { type: Array, default: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] },
availableTimes: Array,
}));
const Booking = mongoose.model('Booking', new Schema({
bookingID: Schema.Types.ObjectId,
bookingReference: String,
name: String,
resourceID: { type: Schema.Types.ObjectId, ref: 'Resource' },
startTime: { type: Date, required: true },
endTime: { type: Date, required: true },
}));
module.exports = { User, Resource, Booking };