Iterate/Loop over lists vs objects from firebase request

I am having many problems with storing entities in firebase. The problem is because when the first entity is registered as a child of an entry, when I do a get request in that entry, I get a list , but when I start adding more childs to that entry, when I do a get request on it, I get an object { }. And it’s easy to iterate over a list, but what can I do when I receive an object ?

This link talks about my problem. And that’s the illustration of the problem:

1 Like

@Menor_Preco, Do you have an example of a project (hopefully a small one) which demonstrates your problem? If so, could you share it here (here’s how)?

-Mark

1 Like

@Mark, I think this is the smallest one I can do:

https://x.thunkable.com/copy/eb5541012edb7ef550c1bc493d19dde4

Usage:

1 - Clear Database
2 - Type a string in the field
3 - Click to register
4 - Wait until the firebase requests end
5 - Wait until the “Registers list” change

You will see that you send a list in the Save Request, but when you do a Get on it, firebase returns an object. And after adding the first register, you can’t add more, because Blockly “crashes” when you try to interpret an object as a list.

1 Like

@Mark, the only way I think I can do what I want is to implement a linked list in firebase, but that’s not a good solution :confused:. I’m bugged with firebase. If you get an idea, give me a light.

Many thanks :slight_smile:.

1 Like

@Menor_Preco I haven’t had a chance to look at your example project yet. Hopefully, once I do I can find a reasonable solution.

-Mark

2 Likes

@Menor_Preco . I believe that you have discovered a bug in our code generation. The workaround that I would suggest would be to replace your uses of Realtime DB component with cloud variables. They can do pretty much everything that the Realtime DB component does only much more simply and they do not have the bug that is causing your problem.

I hope this helps!

-Mark

2 Likes

For now, this solves my problem, thank you !

And I’m also happy to know that I have discovered that bug, I hope this help. :slight_smile:

@Mark, I don’t know if is possible, but I have one doubt: how can I know if the Save Request of the cloud variable failed ?

1 Like

Right now I think the easiest way would be to check whether the cloud variable contains the expected value.