How to avoid duplicate data

I previously opened a post that was masterfully answered regarding writing data to Firebase Realtime using the Web Component.
I tried it and it worked perfectly.

To create a new registration and avoid duplicate data, how would I validate this in this component?

For example, in my registration, I already have the name of a hypermarket: Supermercado BH. When the user tries to register again, they’ll see a message that it already exists.
Would it be something along those lines?

Simple answer is first get the user data and use matching. If match found then throw an alert

When btn_save clicked, first get data from fb using the proper bucket , if it throws empty then use all the blocks showing above else throw an alert

Hi dear,

I think you have three paths you could take.

easy, medium, and hard

Easy

From the client, first check if the name is already present.
This requires downloading the entire node and processing it in the app.

Medium

When creating a hypermarket node, write it in two nodes the first path is where you’re currently writing, and then write it also in another node containing a list of all hypermarkets.

Hard

Cloud Functions (I don’t remember if you need the Blaze pay-as-you-go plan or if it’s available on the free plan) allows you to perform any type of check before executing an operation.
This would be the solution I’d go for, but it requires a bit of study.