Managing multi-user lists in Firebase - Analytics results

Last October, and I would like to express my immense gratitude to our colleague Gianluca Franco for his support on this matter, as he dedicated his time to helping us understand the list management method in Firebase.

I ran a test using my data:
Hypermarket: name of the establishment;
Product: name of the product, resulting in:
Tag (test/parlist): Hypermarket/Epa
Value: Rice.

json
{
“PROJECTBUCKET”: {
“Hipermercado”: {
“BH”: {
“-OphceajH2cN7sPPkPqT”: “Arroz”
},
“Epa”: {
“-Ophckux97wyUcH2uRfi”: “Arroz”
},
"Villefort ": {
“-Ophc0b-XqfnJ7eC3OM9”: “Arroz”,
“-OphcAXfyPd_q7azFsfA”: "Feijão "
}
}
}
}

In the app it looked like this:

When I add the value “Rice” to the “Hypermarket/Epa” tag, it deletes it but keeps the “Villefort and BH Hypermarkets”. To delete the others, i.e., hypermarket/product, it is necessary to enter the name of the hypermarket, obtain the list, and then delete.

I did it another way now. In the tag I put:
Hypermarket/Hypermarket Name/Product/Product Name.

Json:
{
“PROJECTBUCKET”: {
“Hipermercado”: {
“BH”: {
“Produto”: {
“-Ophgk4VLTu_JhjgqG-K”: "Açúcar ",
“-Ophgpk2Lb–Q-YJ5rZX”: “Óleo”
}
},
“Villefort”: {
“Produto”: {
“-OphgQHPUy7o6R8TbTMc”: “Arroz”,
“-OphgaGsxqs3kdgE5pga”: “Feijão”,
“-Ophge3EvFxfVQ-xAGRy”: "Açúcar "
}
}
}
}
}

To delete, I’ll first have to type the tag, get the list, and then delete the object from the list.

Now come the questions:

1 - Product prices. Example:
Supermarket: Villerfort
Product:
Rice
Price:
R$ 20.00.

I’d like the product name and its price to appear in the list. Is that possible?

2 - Since the products don’t have fixed prices, how do I edit these prices?

3 - On the quote screen, how do I get these values: Supermarket, Product, and Price?

1 Like

So you want the result this way…

What’s my suggestion is, to store the items like this in RTDB.

A structured data snippet showing a 'SuperMarket' category with an 'Items' subcategory listing 'Rice' with a quantity of 15. (Captioned by AI)

Don’t add the $ sign in the value of the product. Keep the product name as key and the amount as value. Add the $ sign in the UI section not at the base RTDB.

I remembered that time​:blush::blush::blush:

He’s deserve it, from myself too, this guy he’s very helpful without any expectations when helping anyone. I/am still learning many useful things from our dearly Ray.

Yes this is definitely possible, but from Ray I have leaned something that I think it’s a better option than Firebase database, which is supabase. I was hearing people talking about it, so Ray helped me out set the database to my current project, I found it very useful, it’s support Edge functions, SQL typescript, indexing, tables connection, RLS security, even authentication too, millions API calls, 1 GB free storage (accessed in free plan too, which makes it more than Firebase) the only limitations I hate is project paused after 7 days of inactive. I have set a lot of Edge functions, that helps me protecting some sensitive data, eg some of my API keys, eg I can call initialize payments via Edge functions (off topic)

I think I should asked you, is the project fully developed or still in development?

Also the response of Vega_Star is also powerful.

2 Likes

Hi dear, I hope everything is fine.

To give everyone a reference, this is the guide this project is based on:

As specified, the list items are created using a RecyclerList with a schema,

and to include the price you simply need to modify the schema.
In the project there is a screen called schemaFBListItem, you can modify it by adding the elements you need and then regenerate the schema with the SchemaGenerator

Could you explain better what you mean? What exactly would you like to achieve?


Many thanks dear :heart_hands:


Edit:

I’ve modified the project to allow you to enter both product name and price.


I updated the schema and made the necessary connections for the RecyclerList.

If you have any doubts, feel free to ask.
FirebaseList4Carlos.aia (134.2 KB)

Have a nice day, dear

Giannluca, I made some changes to your app. In addition to including “Price,” you also included Hypermarket and Product Brand. When registering, the list shows: product, brand, and price, but not hypermarket. In your app, to perform a search, the user has to enter the Tag and the PairList, that is, Hypermarket/hypermarketname. Therefore, I would like that as soon as the hypermarket is registered, it populates the spinner, which would greatly facilitate the search process instead of the user having to type to search.

Spinner:
image

This is the result after including hypermarket and brand:

As you can see in the image, I created an edit button whose function, after obtaining the list from the supermarket, would be to change the product data, brand, and price.

The altered aia follows.
FirebaseList4Carlos.aia (136.8 KB)

Hi everyone, since I don’t know if the previous post “Managing multi-user lists in Firebase - Analytics results” has been resolved or not, I’ll open this one here. However, if it becomes redundant, moderators can delete it.

Our colleague Gianluca Franco had created a multi-user list manager in Firebase. @RaYzZz I made some changes to your application. In addition to including “Price”, you also added Supermarket and Product Brand. When registering, the list shows: product, brand and price, but not supermarket. In your application, to perform a search, the user needs to enter the Tag and the PairList, that is, Supermarket/supermarketname. Therefore, I would like that, as soon as the supermarket is registered, it is automatically filled in the selector, which would greatly facilitate the search process, instead of the user having to type to search.

Spinner:
image

This is the result after including the supermarket and brand:

As you can see in the image, I created an edit button whose function, after obtaining the supermarket list, would be to change the product data, brand, and price.

The modified AIA file follows.
FirebaseList4Carlos.aia (136.8 KB)

With your needs, Supabase sounds great to me for creating such engine

Hi dear,

I’m not fully understanding the request, do you just want to add this specific functionality?

If so, wouldn’t it be enough to save the supermarket name in a variable and, when you receive a 200 response from insertUniquePair, set the textbox text to that saved variable? :grin:

What I want is to prevent the user from making a mistake and speed up the search process.
Currently, I have to type the name “Hypermarket/Name” in the Tag/ListPair field and then click “Get List”:

In the new model, when you select the supermarket on the spinner and click Get list, the data appears in the list:

I even tried using the Firebase tag list, but I saw that the Firebase Database component changed to Firebase Realtime Database:

The problem is how to retrieve the Tag value and load it into the spinner.

Edit record. Let’s say I want to edit a record. When I get the list of products/brand/price from Hypermarket X, I want to change these items. For example, from Hypermarket X I want to change the price. I created this edit button but I don’t know how to make it work.

One last question, and sorry for so many. In the schemaFBListItem I created the item “hypermarket”:

And I made the call in RecyclerList_FBList:

But from what I saw, it’s a Tag. Is there a way to get that value?

Hi Carlos,

For the tags, the API allows you to use shallow=true to retrieve only the top-level tags.

I don’t remember exactly how the response is formatted, but I assume it’s a JSON with various key-value pairs set to true.
Using the dictionary keys block, you can then obtain a list of tags to bind to the spinner.

Regarding this, do you want the existing textboxes to be auto-filled so they can then be edited?

I didn’t understand :grin:

I honestly don’t even know how to do this.

These were the settings:

I added the JSON to the project:

I included the Firebase Realtime Database component:

And in the blocks it looked like this:

And the result was this:

image
I’ll put together a step-by-step guide.

I want to change the prices of a certain product/brand at a supermarket “x” that is already registered.
I type the supermarket’s name and click on “get list”.

When the product/brand appears after clicking the edit icon/button, the Product, Brand, and Price fields will appear.

And as soon as you change it from 23.00 to 22.00 and then click on Register, the value will be changed.
I only put the price here, but the change could also be made for the product and brand.

In summary, to avoid confusion and doubt, as these are two different proposals:
1 - When registering the Hypermarket/Name, populate the Spinner as well. Spinner functionality. Currently, to obtain the list of products/brands/prices of a hypermarket “x”, the user has to type in the Tag/ParList field: Hypermarket/HypermarketName and then click on GetList.

What I want is that when selecting the Hypermarket/HypermarketName in the Spinner, click on GetList. Reason: to prevent them from typing incorrectly and to speed up the process.

2 - Edit a registered record. Possibility to change: brand, product and price already registered.

Hi dear,

In Companion, FirebaseRealtimeDatabase does not work as described in the migration guide.

Be careful! If your project doesn’t have security rules, at least don’t make its address public.

Looping through all tags to get the values of each node is not recommended.
Usually, you download the parent node of the tags so you can retrieve all of them along with their values, and then use the dictionary keys block to get all the tags.

Alternatively, you can download all the tags and, upon each spinner selection, retrieve the data for that specific tag.

But aren’t you already doing that? :grin:

I remember I mentioned supabase 2 time’s, we cannot build a database and not able to test in companion, companion with database must work together in order to reduce a lot of work here, imagine if I misplaced a tag, am supposed to destroy the whole code and compiled 1 by 1 in order to address where the error may be?


Before this change, it worked in the companion app, but thanks for the tip.

@RaYzZz
I did it this way.

In the Firebase Realtime component, I put “hypermarket” in the path.
In the “get list” button, I cleared the global “hypermarket_list” and called Firebase_Realtime_Database GetTagList (I did this instead of calling it on initialization).
I didn’t use Got Value, only Tag List.
Here are the blocks and the result:

Is it correct now?
Can you help me with editing the data?

Hi dear,

Sorry, I forgot to show you how to use shallow=true so you can also test it in Companion


It all seems correct

Edit:
Hi dear, sorry there was an emergency and I had to leave.
I was just able to make a couple of changes for you, but I have to go again.
I’ll start sharing the project with you, if I can, as soon as I’m back I’ll explain what I added.


Carlos.aia (140.9 KB)

1 Like

It worked, Giannluca!
I created three more fields: unit of measure, packaging type, and unit of measure value.
Everything went well.
Now the challenge for me is to add an image to the list, for example, an image of rice.

:partying_face::partying_face::partying_face:

First of all, you need to decide where the images will be stored, Firebase offers storage space if you upgrade to the Blaze plan, otherwise, you can rely on some hosting service.

I don’t want to use Firebase for image storage; I prefer Cloudinary.
I want to place the image in this position here, and I believe I need to modify the schema.
I’m open to suggestions.

Perfect! Then you just need to add a button that uploads the image to Cloudinary, and as soon as you receive the URL, call firebaseInsertUniquePair or firebaseEditUniquePair by adding an image field to the dictionary with the received URL.

Then, in the schema, as you correctly guessed, you’ll need to add an image component that you set with the value of image in OnBindView.