在Firestore数据库中查询文档ID [英] Query firestore database for document id

查看:75
本文介绍了在Firestore数据库中查询文档ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Firestore数据库中查询文档ID.目前,我有以下代码:

I want to query a firestore database for document id. Currently I have the following code:

db.collection('books').where('id', '==', 'fK3ddutEpD2qQqRMXNW5').get()

我没有得到结果.但是当我查询其他字段时,它会起作用:

I don't get a result. But when I query for a different field it works:

db.collection('books').where('genre', '==', 'biography').get()

如何命名文档ID?

推荐答案

尝试一下:

db.collection('books').doc('fK3ddutEpD2qQqRMXNW5').get()

(第一个查询正在寻找一个名为"id"的显式用户设置字段,该字段可能不是您想要的.)

(The first query is looking for an explicit user-set field called 'id', which probably isn't what you want.)

这篇关于在Firestore数据库中查询文档ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆