How to conditionally add a new record, when a null is present in the ID?

Hi All, fairly new here migrating to Xano, moving away from bubble.io thanks to their completely misguided pricing model changes. Having a few challenges trying to migrate some core parts of the DB into Xano. I come from a DBA background, so I'm quite comfortable with the underlying structure.

My specific use case is that I have several related tables (which are queried first for performance reasons), and only if a 3rd table has data - it should then be updated, but if the relevant record in the 3rd table is missing, it should be created. What this means in practice, is I have a query with several joins (inner & left joins), with an addon in the output from that query for the data in the 3rd table. In cases where the 3rd table has no record, I get a null for the addon in the output from the main query. This results in an error being thrown as: Exception: Param: field_value - Missing param: field_value.

What I was expecting was that if a null value is provided as the field_value, that this would be interpreted as 'a new entry should be created, since the existing couldn't be found or doesn't exist', but instead I get an error that the value is missing. I could do a workaround with a conditional if/then to check if that field is null, but this adds complexity and slows down the processing, and seems like a simple thing Xano should be able to help with: if the lookup field is null, assume that record doesn't exist and add it.

Unless I'm missing something?

P.S. I am using the 'id' field in the 3rd table (which does the add/edit record) for the lookup, to ensure I am matching the existing records atomically.

6 replies