I have a list of URLs that are linked to the user. Currently, once the user adds those URLs to the app, I’m saving each URL as an individual document and then read any document that matches their UID.
Is this the right way to do it?
And with Firestore, is it cost per read per document or read per item no matter if there are 100 items in one document?
Just trying to wrap my head around it so any help would be great!
2
Answers
In my opinion you should save URL’s in an array for every user. Because firebase charges you for one document read for each batch of up to 1000 index entries matched by the query.
Check this link for more details:
Not quite the best solution. While this solution will definitely work, it’s a little costly because you’ll have to pay a read operation for each document you read. In my opinion, the best option that you have is to store those URLs in an array in the user document. The schema should look like this:
It’s always a read-per-document, no matter how many fields exist inside the document.