如何在python中检索firestore where查询返回的记录数?

如何在python中检索firestore where查询返回的记录数?,python,firebase,google-cloud-firestore,Python,Firebase,Google Cloud Firestore,我试图获取Firebase集合中查询返回的记录数,但无法检索查询返回的记录数 从google.cloud导入firestore作为cloud\u firestore firestore=cloud\u firestore.Client() posts\u ref=firestore.collection('posts')) docs=posts\u ref.where('slug','=',post['slug'])。stream()#是一个可以循环的iterable #这是一个错误;TypeE

我试图获取Firebase集合中查询返回的记录数,但无法检索查询返回的记录数

从google.cloud导入firestore作为cloud\u firestore
firestore=cloud\u firestore.Client()
posts\u ref=firestore.collection('posts'))
docs=posts\u ref.where('slug','=',post['slug'])。stream()#是一个可以循环的iterable
#这是一个错误;TypeError:类型为“generator”的对象没有len()
如果len(docs)!=0:
打印(“帖子已经存在!”)
退出()
#将_post_添加到_db()。。。

请有人帮助我如何获取此查询返回的记录数。我很难理解这一点。

需要将生成器转换为列表

docs=list(posts\u ref.where('slug','=',post['slug']).stream())

docs.len,docs.size,docs.size()。。。?