Unable to get query using dynamic table
I want to retrieve data with the filter userId is this.userId. but when I do it with dynamic table name I get an error:
this is the example code in my case:
7 Replies
any suggestion or advice guys?
can you try it by running in the Queries (Typescript) with a snippet like this:
the above seems fine for me:
I'm thinking that the issue for you might be that
userId
is of type string
@SferaDev is the expert hereWhen using a dynamic table, the schemas become a union of all tables and type safety might be lost, you can attempt to cast the table name property to one that you know the schema is correct to get proper types.
I tried that way and it works, the problem is when the dynamic table variable is a prop
but i have unpredictable and scalable client, which is 1 client 1 table
Instead of getXataClient() you can create the BaseClient and pass the tables as parameter in the client constructor, but you'll loose all type safety.