error while inserting the data in the dynamic table

Hi, I am trying to insert the data which is coming from the form into the table, so, I am using this
const tableName = data.tableName
await db.insert(tableName).values()
res.status(201).json({
status: "success",
message: "Data inserted successfully",
});
const tableName = data.tableName
await db.insert(tableName).values()
res.status(201).json({
status: "success",
message: "Data inserted successfully",
});
but I am getting an error that
Argument of type 'string' is not assignable to parameter of type 'PgTable<TableConfig>'.ts(2345)
Argument of type 'string' is not assignable to parameter of type 'PgTable<TableConfig>'.ts(2345)
3 Replies
Boby
BobyOP7d ago
however my data.tableName is of type string is there any way to do this with static typed drizzle or I will have to use the raw sql to do this?
Boby
BobyOP7d ago
No description
Boby
BobyOP7d ago
hope, I am clear enough with my question

Did you find this page helpful?