What I'm trying to do:
I have a function stack that requires me to be able to run dynamic database operations on tables that aren't predefined
I have 50+ tables
I need to be able to create, read, update, and delete records in all 50+ databases -- without knowing which database needs to be queried (and what columns are impacted) before-hand
For example, given an arbitrary database and an arbitrary set of key-value pairs, I need to be able to add a record that contains all of the key-value pairs.
I cannot use standard CRUD endpoints:
My function stack is for complex AI workflows, and requires custom parameters to be passed in between API calls.
That means that I would need to create hundreds of custom CRUD API points with a specific input structure and duplicated logic to use this approach -- which is massively unscalable and creates a ton of future refactoring work
While in theory, this shouldn't be impossible -- it seems in Xano's current form, it is.
Xano's Pre-Built Database Functions
Xano's prebuilt database functions require defining a specific database to run the operation on. There is no way for the table being queried to be dynamic.
This means that, in order to be able to query an arbitrary database, I need to create a hardcoded tree of conditionals for every database and every database operation. Again, this is a massive amount of work and a nightmare for future refactoring.
Xano's Direct Query Builder
Xano's Direct Query function also has major limitations.
I managed to create a function stack that uses the metadata API to retrieve the database ID and build an identifier that can be used to dynamically query an arbitrary database.
HOWEVER -- it appears to be impossible to run a query with a variable number of values.
The query component of the function can't be a custom expression
The number of placeholders must match the number of args
So there's currently no way to build a function that will allow me to update a dynamic number of fields. The number of fields to be updated must be predefined in function
Question to You
Am I missing anything, or am I trying to do something impossible?
Is there another way to run arbitrary database operations on an arbitrary table? Or do I have to go through the massively painful experience of hardcoding conditional trees for every possible operation?