【问题标题】:New Google Cloud Firestore in Datastore mode Queries ClarificationDatastore 模式下的新 Google Cloud Firestore 查询说明
【发布时间】:2019-06-08 12:09:32
【问题描述】:

在使用新的 Google Firestore Datastore 模式(我已经使用过以前版本的 Datastore)时,我很难理解查询是如何在事务上真正起作用的。

根据documentation,这些是在数据存储模式下使用 Google Cloud Direbase 的好处:

  • 最终一致性,所有 Cloud Datastore 查询都变得高度一致。
  • 事务不再限于 25 个实体组。
  • 对实体组的写入不再限制为每秒 1 次。

由于查询现在是高度一致的,我认为在事务中使用非祖先查询是可以的,但在 documentation 中另有说明:

事务中的查询必须是祖先查询

深思熟虑后,我决定试试看我的怀疑是否正确:

query := datastore.NewQuery("Entity").Filter("indexed_property =", s)
ctx := context.Background()
tx, err := client.NewTransaction(ctx, datastore.ReadOnly)
if err != nil {
  fmt.Pritnln(err)
}
query = query.Transaction(tx)
it := d.client.Run(ctx, query)
e := new(Entity)
_, err = it.Next(e)
if err != nil || err == iterator.Done {
  fmt.Println(err)
}

令我惊讶的是,它完美无缺。所以这是一个错误还是正确的行为?

【问题讨论】:

    标签: google-cloud-firestore google-cloud-datastore


    【解决方案1】:

    你是对的。这是文档中的一个错误。 Datastore 模式下的 Cloud Firestore 消除了事务内的查询必须是祖先查询的限制。

    页面现已更新。对造成的混乱表示歉意。

    【讨论】:

      猜你喜欢
      • 2023-03-20
      • 1970-01-01
      • 2019-08-09
      • 2020-01-29
      • 2018-08-06
      • 2019-03-22
      • 2020-01-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多