title: How to query a field inside an array from Firestore
body: <p>I have a collection in my project where I am trying to only fetch the relevant documents to my project.</p>
  <p>My firestore looks like so:
  <a href="https://i.stack.imgur.com/n07Js.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n07Js.png" alt="Firestore collection" /></a></p>
  <p>I am trying to only get the projects that contain the logged in user.
  I only want to fetch the ones where one of the UID's in the users array matches the current users UID.</p>
  <p>How do I filter the query to only get those in SwiftUI?</p>
  <p>This is my ProjectRepository where I fetch the projects:</p>
  <pre><code>class ProjectRepository: ObservableObject
  {
      var userId = &quot;&quot;
      
      private let fbAuth = FBAuth()
      
      private var cancellables: Set&lt;AnyCancellable&gt; = []
      
      private let store = Firestore.firestore()
      
      @Published var projects: [Project] = []
      
      init()
      {
          fbAuth.$user
              .compactMap { user in
                  user?.uid
              }
              .assign(to: \.userId, on: self)
              .store(in: &amp;cancellables)
          
          fbAuth.$user
              .receive(on: DispatchQueue.main)
              .sink { [weak self] _ in
                  self?.get()
              }
              .store(in: &amp;cancellables)
      }
      
      // Retrieve projects from firebase
      func get()
      {
          store.collection(FirestoreKeys.CollectionPath.projects)
              .addSnapshotListener { querySnapshot, error in
                  
                  if let error = error {
                      print(&quot;Error getting projects: \(error.localizedDescription)&quot;)
                      return
                  }
                  
                  self.projects = querySnapshot?.documents.compactMap{ document in
                      try? document.data(as: Project.self)
                  } ?? []
              }
      }
      
      // Add projects to firebase
      func add(_ project: Project)
      {
          do {
              _ = try store.collection(FirestoreKeys.CollectionPath.projects).addDocument(from: project)
          } catch {
              fatalError(&quot;Unable to add card: \(error.localizedDescription)&quot;)
          }
      }
  }
  </code></pre>