0

thanks so much in advance for your help

In firebase admin I would like to run a function to fix a data model issue.

I have a collection of documents x

each document in x may or may not have a subcollection of documents y

I would like to update all of the docs in y with data from the parent doc x

x1 {y1, y2, y3 ...} 
x2 {y1, y2, y3, y4 ...} 
x3 {null} 
x4 {y1, y2 ...} 

for example document x1 will update it's 3 y docs with data from x1 for example document x3 will update it's 4 y docs with data from x3 nothing will happen to x3 etc.

Basically the y docs are read far more than x docs so i don't want to call x every-time i need a small piece of data in y i'd just like to run one script that adds that piece to y's

Zeenath S N
  • 1,100
  • 2
  • 8
atx123n
  • 33
  • 2
  • 7
  • Sounds like a clear use-case. Where in implementing it are you stuck? – Frank van Puffelen Dec 07 '21 at 04:24
  • Hi, can you explain ```for example document x1 will update it's 3 y docs with data from x1 for example document x3 will update it's 4 y docs with data from x3 nothing will happen to x3 etc.``` more clearly if possible? – Zeenath S N Dec 07 '21 at 11:06
  • Basically wondering the best solution to reduce reads. Not too familiar with the methods of doc ex. parent etc. – atx123n Dec 07 '21 at 17:50
  • the y docs are supposed to represent the sub collection – atx123n Dec 07 '21 at 17:50
  • Can you check if [Reduce number of reads for a large collection](https://stackoverflow.com/a/60535986/15774177) helps to answer your question? – Zeenath S N Dec 09 '21 at 07:39

0 Answers0