小编f4h*_*him的帖子

我的房间预订 MongoDB 架构应该是什么?

我正在用nodejs构建一个房间预订系统。目前我有hotels,roomsbookings作为收藏。

rooms被引用hotelsbookings被引用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)

mongodb node.js

5
推荐指数
1
解决办法
1726
查看次数

标签 统计

mongodb ×1

node.js ×1