How to update a node reference in Firebase to another node?

Asked

Viewed 39 times

1

Estrutura do banco

I have in the database structure with 2 nodes ("location" and "lot"). Within the "batch" structure, I have a "location" reference in the "local_lot" attribute, as described in the image. When updating the attribute (local capacity) of the "local" node, its reference within "batch" has not been updated. Should this update procedure be manual? Is there any way to update automatically? I’m new with Firebase, so this way would be the best way to structure? Thank you from now!

1 answer

0

welcome to our community.

Answering to your questions:

The first thing I noticed from your screen print is that you are using the Realtime Database. Is there a real need to use the Realtime database? Does your system have a lot of competition and needs high availability? I don’t think so. So instead of Realtime Database, use Firestore.

Using the Firestore, you have an interesting feature that are the subcollections (subcollections), precisely for you to make similar associations.

I understood that in the modeling you did, a site can contain several batches associated with it correctly?

In the Firestore, just create the "local" collection and in each document, you can create a "batch" undercutting and there yes in it you add batch elements. Thus you avoid reference duplicity and the organization gets much better.

You’ll find plenty in this official Firestore documentation

Browser other questions tagged

You are not signed in. Login or sign up in order to post.