Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于检查房间可用性的MongoDB/Mongoose模式_Mongodb_Mongoose_Mongodb Query_Mongoose Schema - Fatal编程技术网

用于检查房间可用性的MongoDB/Mongoose模式

用于检查房间可用性的MongoDB/Mongoose模式,mongodb,mongoose,mongodb-query,mongoose-schema,Mongodb,Mongoose,Mongodb Query,Mongoose Schema,我有一个旅馆房间的方案 const { Schema, model } = require('mongoose'); const reservationSchema = new Schema({ checkIn: { type: Date, require: true }, checkOut: { type: Date, require: true },

我有一个旅馆房间的方案

    const { Schema, model } = require('mongoose');

    const reservationSchema = new Schema({
      checkIn: {
        type: Date,
        require: true
      },
      checkOut: {
        type: Date,
        require: true
      },
      status: {
        type: String,
        require: true,
        enum: ['pending', 'cancel', 'approved', 'active', 'completed']
      }
    });

    const roomSchema = new Schema(
      {
        title: {
          type: String,
          required: true
        },
        slug: {
          type: String
        },
        description: {
          type: String,
          required: true
        },
        capacity: {
          adults: {
            type: Number,
            required: true
          },
          childs: {
            type: Number,
            default: 0
          }
        },
        roomPrice: {
          type: Number,
          required: true
        },
        gallery: [
          {
            type: String,
            require: true
          }
        ],
        featuredImage: {
          type: String,
          require: true
        },
        reservations: [reservationSchema],
        isAvailable: {
          type: Boolean,
          default: true
        },
        isFeatured: {
          type: Boolean,
          default: false
        },
        isPublish: {
          type: Boolean,
          default: false
        }
      },
      { timestamps: true }
    );

module.exports = model('Room', roomSchema);
现在我想找一些没有预定特定日期的房间

示例:如果搜索查询为签入:2019年12月25日和签出:2019年12月30日,则查询结果将显示此期间未预订的房间。此外,如果预订状态为取消,它将显示预订的房间

我怎样才能做到这一点?
我是否需要更改模式设计以实现此目的?

@SuleymanSah Yeah如果预订状态为“取消”,则日期将显示为可用。请在jsoneditor online上共享输入数据和输出