• 4
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I was wondering if there was a way of getting a sub collection after using .where

This is my database format

  • Users <-- collection
  • Bob123
  • posts <-- sub collection
  • post1

Firestore.instance.collection("Users")
.where("followers", arrayContains: id)  //id is the users id 
//He i want to get the collection of posts that the particular user has posted

Subcollections are under an individual document, while a query identifies a group of documents. If when you know that the query only identifies one document, the Firestore client doesn't know that, and even if it did, it doesn't know the full path for that document.

You first need to execute the query, then get the individual documents, and then you can get the subcollection of each document.

  • 1
Reply Report