Firebase Firestore:查询并获取其中一个字段中包含查询值的文档

Firebase Firestore: Query and get documents that contain the queried value in one of the fields

是否可以查询一个集合和return文档,其中一个字段包含查询值,而不管它是哪个字段?

例如,一个典型的查询是这样的:

db.collection('collection').where('id','==',targetvalue).get()

让我们假设一个假设场景,其中集合下的文档中的任何字段都可以包含目标值。是否可以查询此类文件?如果可以,我该怎么做?

Is it possible to query a collection and return documents that contain the queried value in one of the fields, regardless of which field it is?

不,您不能这样做,除非您为每个字段创建不同的单独查询:

db.collection('collection').where('id','==',targetvalue).get()
db.collection('collection').where('otherField','==',targetvalue).get()
//And so on.

您无法在文档的所有字段中搜索值。如果您正在考虑使用通配符,请注意这在 Firestore 中是不可能的。