问题描述
可以使用getter属性 path
将 CollectionReference
表示为字符串.这对于单元测试非常方便.例如, admin.firestore().collection('cities').doc('LA').path
返回"cities/LA"
It is possible to represent a CollectionReference
as a string with the getter proprety path
.This is very handy for unit tests.For example admin.firestore().collection('cities').doc('LA').path
returns "cities/LA"
以String表示的 Query
怎么样?
What about Query
represented as String ?
例如,有一种方法可以实现这样的 admin.firestore().collection('cities').where('name','==','LA').toString()
来打印这样的内容:" cities/{where $ name =='LA'}"
For example is there a way to something like this admin.firestore().collection('cities').where('name','==','LA').toString()
to print something like this this: "cities/{where $name=='LA'}"
这对于单元测试很方便
推荐答案
来自此文档,您可以看到Query类的继承成员使用toString.这是您要找的吗?
From this document, you can see that the inherited members of class Query uses toString. Is this what you are looking for?
这篇关于可以将Firestore查询表示为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!