I still think that if the amount of data you are going to handle is not very large, it would be better to recover it all and do the searches then. Everything would be much simpler
It is possible, but you would need to structure your data differently. You would need another "node" that listed each compatible item and its PN item as a sub-node e.g
recambios
123ABC
Compatible: ["ABC123","ABD123","ABE123"]
Description: "3TB HDD"
PN: "123ABC"
compatibles
ABC123
PN:"123ABC"
Description: "3TB HDD"
ABD123
PN:"123ABC"
Description: "3TB HDD"
ABE123
PN:"123ABC"
Description: "3TB HDD"
In this way you can query the recambios table for descriptions, and compatibles for...compatibles
It does appear heavy handed and a duplication. Firebase call this de-normalising, and generally recommend this approach to make it possible to access and query subsets of data.
It would not take much to create this second structure when new records are added.
The fun would start when you have more than one part number that is compatible with a compatible!!
I have thought of the following, which might be easier to do, I have created two compatible ones
compatible and compatible1 creating a new structure, but I do not know how to make it search and find me in compatible or compatible1.
with the blocks that I have that you made me, I can only do it with & and I have to have the two search fields filled, I do not know how to do the search "or".
{"1111":{"Compatible":""22222"","Compatible1":""3333"","Descripcion":"""","PN":""1111""}}
Could you help me ?
You cannot do OR queries in firebase (realtime database)
You would have to do a query for compatible, then another for compatible1....
Hello
Do I need 2 search buttons or 2 web components or do I have to do some conditional in the blocks?
Thanks in advanced
Before we go there, what will you do if you have 4, or 5, or more compatibles ?
I have reduced it to 2, it already works for me with that amount,
When I have more time, I'll try to modify the firebase structure as I see fit.
To answer this, it depends on what you want to happen. If you run the first compatible check, if you get a result, do you then run the second anyway? How many results do you want returned, just the one ?
I need you to show me what is in compatible and compatible1 in case you have data, starting to search for compatible
For example, if I put 22222 it also shows me compatible1 and if I put 3333 it also shows me compatible
A little logical data modelling here...
If A is compatible with B, and
B is compatible with C,
is A always compatible with C?
If that were the case, having B and C point back to A for compatibility would change the data structure to eliminate lists at the part level.
If you need a replacement for B, check what B is compatible with (A),
then search for all parts that are compatible with A (A,B,C)
Forgive me if I missed problems with this approach earlier in this long thread.
I believe I handled this, in Firebase (the Firebase way) here:
but the OP has not chosen that route
perfect, it works as I wanted it to, thank you very much for your help.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.