查询 Firestore 数据库以获取文档 ID [英] Query firestore database for document id

查看:37
本文介绍了查询 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的名字是怎么叫的?

How is the name of the document id called?

推荐答案

试试这个:

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天全站免登陆