0

I am working with two collections:

Agency:

  • id
  • title
  • description

Packs:

  • id
  • offer
  • agency (map: {businessId (string), title (string), description(string) })

Agencies can have many packs, but each pack can only have one agency.

In Firebase

enter image description here

Do I have to manually enter the information for the reference map, or is it done automatically? I come from SQL.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Lakos
  • 1
  • 1
  • Firestore won't do anything automatically for you. You have to enter all the data, or more typically, write code to read and write the data. – Doug Stevenson Jun 28 '23 at 17:41
  • I understand. That code has some type of name to look on google? Thanks – Lakos Jun 28 '23 at 17:52

1 Answers1

0

Do I have to manually enter the information for the reference map, or is it done automatically?

As @DougStevenson mentioned in his comment, there is nothing that is done automatically in Firestore. To denormalize the data, you can write the duplicate data from the client, or you can write a function in Cloud Functions for Firebase, that can copy the desired data to a new location without your interaction. The latter is the preferred technique because it performs the second write automatically.

P.S. In Firestore, there are no tables, there are only collections, so I edited your question accordingly.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193