[英]Is .document(uid) the same with .whereEqual("uid", uid)?
Is this operation:这个操作是:
db.collection("users").document(uid)
The same with:与以下相同:
db.collection("users").whereEqual("uid", uid)
If a specific uid does not exist, are we still charged with a read operation?如果特定的 uid 不存在,我们是否仍然负责读取操作? Is this available in both cases?
这在这两种情况下都可用吗? Note, that the document is not created yet, there is nothing that can be read.
请注意,该文档尚未创建,无法读取任何内容。
This code:这段代码:
db.collection("users").document(uid)
Does not cost any document reads.不花费任何文档读取。 No document has been read yet.
尚未阅读任何文档。 The only thing it does is build a DocumentReference object that can be used to
get()
the document (or add a listener).它所做的唯一一件事就是构建一个 DocumentReference object 可用于
get()
文档(或添加侦听器)。 The get()
costs a document read. get()
需要读取一个文档。
This code:这段代码:
db.collection("users").whereEqual("uid", uid)
Also does not cost a document read until you call get()
(or add a listener).在您调用
get()
(或添加侦听器)之前,也不会花费文档读取费用。 But if you do call get()
, then it will always cost at least one document read, even if no document is present.但是,如果您确实调用了
get()
,那么即使没有文档存在,它也总是至少需要读取一份文档。 This is covered in the documentation for pricing :这包含在定价文档中:
There is a minimum charge of one document read for each query that you perform, even if the query returns no results.
对于您执行的每个查询,即使查询未返回任何结果,也至少会收取一份文档读取费用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.