我正在用nodejs构建一个房间预订系统。目前我有hotels,rooms和bookings作为收藏。
rooms被引用hotels和bookings被引用rooms。
预订.js
const bookingSchema = new mongoose.Schema({
room: {
type: mongoose.Schema.Types.ObjectId,
ref: 'rooms'
},
start: Date,
end: Date
});
Run Code Online (Sandbox Code Playgroud)
房间.js
const roomSchema = new mongoose.Schema({
roomid: String,
hotel: {
type: mongoose.Schema.Types.ObjectId,
ref: 'hotel_managers'
},
type: String,
price: Number,
capacity: Number,
facilities: [String],
amenities: [String],
img: [String]
});
Run Code Online (Sandbox Code Playgroud)
酒店.js
const hotel_manager_schema = new mongoose.Schema({
username: {
type: String,
required: true,
unique: true
},
password: {
type: String, …Run Code Online (Sandbox Code Playgroud)