{
_id: ObjectId("600631c7c8eb4369cf6ad9c8"),
name: "Market X",
openHour: 10, // number between 0 and 23
openMinute: 30 // number between 0 and 59,
closeHour: 18, // number between 0 and 23,
closeMinute: 30, // number between 0 and 59
weekDay: 1 // number beetween 1 and 7
}
使用这样的模型,您可以进行查找:
{
weekDay: 1, // number between 1 (Monday) and 7 (Sunday)
openHour: { $lte: 11 }, // number between 0 and 23
openMinute: { $lte: 32 }, // number between 0 and 59
closeHour: { $gte: 17 }, // number between 0 and 23
closeMinute: { $gte: 20 } // number between 0 and 59
}
1条答案
按热度按时间llycmphe1#
你可以使用小时和分钟。首先你需要创建字段,如果你有多个时间依赖于工作日,你也可以使用数组。
使用这样的模型,您可以进行查找:
find中的查询参数可以通过time和day.js实现,例如dayjs().format(“HH”)将检索节点运行的实际时间。