0

I am using Firestore to build my app. But I'm having the issue that I need to get all users to recommend users other users. Currently, I solve this issue by writing all data that I need for the loop in an overview document inside my users collection. But I'm realizing that a single document can only be 1 MB. That means I can only store ~1000 users.

Example of my database

{
  'users': {
    'userId': 'username'
  }
}

How I can solve this?

Tutorialwork
  • 63
  • 2
  • 9
  • https://stackoverflow.com/a/48635757/7015400 You can have as many documents as you want under one collection.. so if each document is for one user, you can have more than 1000 users – Peter Haddad Jul 18 '20 at 10:53
  • Yes but I want the data from all users in a array but when I do this and I have for example 10000 users, I can only loop all users 5 times on each day with my free quota. This is my problem. – Tutorialwork Jul 18 '20 at 11:05

1 Answers1

0

The 1MB limit per document is a hard limit. It can't be exceeded. If you have more items than can fit in a single document, you will need to move those items into individual documents. Usually people use a nested subcollection for this.

If you are running into limits with your free allowance, obviously you will have to upgrade to a paid plan. These limits simply cannot be exceeded and can't be designed around.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441