user13466745
user13466745

Reputation:

Firestore check if array in specific document contains a value

I would like to check if the array "devices" which is in the document "SOjTxEjMwb71isiiPnR8" contains the value "AE0EBAFA-1560-404B-A3DA". I just want to know this specific array in the specific document. Because it can be that the same value in the same array occurs in another document. How do I have to do this in Swift? Thanks a lot for your help.

Firestore Image

Upvotes: 1

Views: 373

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598797

You're looking for the array-contains operations, which in Swift looks like this:

devicesRefRef
  .whereField("devices", arrayContains: "AE0EBAFA-1560-404B-A3DA")

You can then get the results once or listen for realtime updates. You'll note that all links I provide are to the relevant sections of the documentation, so I recommend spending some time there.

Upvotes: 3

Related Questions