我需要检查 key (即用户名)是否存在。 It seems KEY_RESERVED_PROPERTY 是可用于 java api 的特殊 key ,您可以使用它来实现最佳性能和强一致性,所以我想知道 Go 中是否有任何等效项。
目前我正在考虑使用用户名作为祖先 + KeysOnly() 的查询。
最佳答案
如果你look at the docs , KEY_RESERVED_PROPERTY
只是一个引用 key 的属性:
A reserved property name used to refer to the key of the entity. This string can be used for filtering and sorting by the entity key itself.
所以这没什么神奇的,您可以在 Go 中使用 __key__
属性做同样的事情,如 in the docs 所述:
Key filters
To filter on the value of an entity's key, use the special property
__key__
:
q := datastore.NewQuery("Person").Filter("__key__ >", lastSeenKey)
关于google-app-engine - Go API 的 KEY_RESERVED_PROPERTY 等价物是什么?数据存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29551986/