Android Firestore querying particular value in Array of Objects

后端 未结 2 2050
悲哀的现实
悲哀的现实 2020-12-12 07:55

This is my structure of the firestore database:

Expected result: to get all the jobs, where in the experience array, the lang value is \"Swift\".

So

2条回答
  •  甜味超标
    2020-12-12 08:54

    With your current document structure, it's not possible to perform the query you want. Firestore does not allow queries for individual fields of objects in list fields.

    What you would have to do is create an additional field in your document that is queryable. For example, you could create a list field with only the list of string languages that are part of the document. With this, you could use an array-contains query to find the documents where a language is mentioned at least once.

    For the document shown in your screenshot, you would have a list field called "languages" with values ["Swift", "Kotlin"].

提交回复
热议问题