1

Firestore collection for office doc like this

{
 officeId: 'OF005'
 userIds:[
   "U001",
   "U002",
   "U003",
   "U004",
   "U005"
 ]
},
{
 officeId: 'OF005'
 userIds:[
   "U006",
   "U007",
   "U008",
   "U009",
 ]
}

In react native app, I connect firestore like this

    firestoreConnect(props => [
    { collection: 'office',
      where: ['userIds', '==', props.id],
    },
  ]),

and prop.id is the id of user I want to get all offices he works

or I want to search by office id some thing like this

firestoreConnect(props => [
    { collection: 'office',
      where: ['officeId', '==', ["OF001", "OF003", "OF004"]],
    },
  ]),

can i do this.

KENdi
  • 7,576
  • 2
  • 16
  • 31
Lakshan
  • 208
  • 1
  • 4
  • 17
  • See https://stackoverflow.com/questions/46721517/google-firestore-how-to-get-document-by-multiple-ids-in-one-round-trip and https://stackoverflow.com/questions/46726673/firebase-firestore-or-query and https://stackoverflow.com/questions/46805749/firebase-firestore-or-query-alternative and https://stackoverflow.com/questions/46719441/google-firestore-what-is-or-equivalent and https://stackoverflow.com/questions/48028440/how-to-accomplish-where-in-query-in-cloud-firestore – Frank van Puffelen May 04 '18 at 13:33

1 Answers1

1

You will need to use a Map of Values. Take a look at Working with Arrays, Lists, and Sets

Jason Berryman
  • 4,760
  • 1
  • 26
  • 42