基于设置为 Object 的文档字段内的布尔值进行查询

Guy*_*Guy -1 go firebase google-cloud-firestore

所以我有一个集合:

rootCollection -> document1 -> "field" : {"flag":true, "name" : "test1"}

rootCollection -> document2 -> "field" : {"flag":false, "name" : "test2"}

rootCollection -> document3 -> "field" : {"flag":true, "name" : "test3"}

所以我的文档包含一个字段“field1”,它是一个对象。

我想进行查询以获取我的“标志”设置为 true 的有效文档。

因此在这个例子中只返回文档 1 和 3

我怎样才能做到这一点?

Ked*_*tna 5

这是您要找的吗?

documents := client.Collection("collection_name")

documents_that_are_true = documents.Where("field.flag", "==", true)
Run Code Online (Sandbox Code Playgroud)