是否可以强制仅在与当前日期同一天时才更新时间戳字段?

Is it possible to enforce that a Timestamp field is only updated if it is on the same day as the current date?

我有一个预订应用程序,用户可以在其中更改他们的预订时间,但前提是新时间与他们预订的当天是同一天。技术上是否可以在 firestore 上强制执行此操作?

您可以将文档中的日期与 request.time variable, which is the timestamp on the server. Assuming that the field in your document is a Firestore Timestamp 进行比较,您可以比较两个时间戳的 yeardayOfYear 属性。如果两者相同,则字段中的值为当前日期。