gpt4 book ai didi

firebase - 酒店预订系统的 Firestore 数据结构

转载 作者:行者123 更新时间:2023-12-02 19:30:32 27 4
gpt4 key购买 nike

我想建立一个酒店预订系统,该系统也可以将可用性推送给 channel 经理。我想使用 Firestore 来存储我的数据。我读了几篇文章,但对此仍然很陌生。

我计划使用这样的结构来设置我的数据库:

collection: "reservations"

fields: reservation_id, status, name, email, check-in date, check-out date, room_id, etc

collection: "rooms"

fields: room_id, room_type, room_number,etc

collection: "availability"

fields: room_id, date, isAvailableexamples: {room_id: 1, date: "2018-10-05", isAvailable: true}, {room_id: 1, date: "2018-10-06", isAvailable: true}

这些是我需要的一些情况:

Situation: A new booking is created

I will create a new "reservation" doc and I will also update the "availability" docs for these dates.

Situation: A multi-calendar view of all rooms

I will get all docs for the dates and rooms and display in a grid

我的问题是:

(1) 这是为 Firestore 设置的最佳结构吗?

(2) 我需要将“availability”设置为“rooms”的子集合吗?

唯一的问题是我需要经常获取所有房间的可用性,这样会导致大量的读取操作。

(3) 我是将 Date 存储为时间戳对象还是字符串?没有涉及小时/分钟的时间,所以它对我来说看起来有点太多了,我喜欢“2018-10-05”,它看起来很整洁。

(4) 创建新预订时如何编写查询以更新可用性?如何获取我想要的日期范围?

感谢您阅读我的问题:)

最佳答案

I recommend you to add dateCreated to reservations.

对于房间,您还应该添加楼层(1st/2nd)以及酒店级别(我的意思是5/4星)

您还需要一个酒店集合,包含其 ID、名称、位置、星级、是否有餐厅、是否有 parking 位等。

关于firebase - 酒店预订系统的 Firestore 数据结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52527094/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com