Automatically Converting SQL Column Names to SnakeCase in Insert Statements
Is there any way how to automatically convert columns into snakecase?
For example when working with sql.insert function. I would love it to automatically convert the object to snakecase so i get the following code to run this query
INSERT INTO user (user_name, pass_word) VALUES (test, test2)
INSERT INTO user (user_name, pass_word) VALUES (test, test2)
:
I know I can write my own transform function but someone must have certainly solved this problem before
const dataToInsert = { userName: 'test', passWord: 'test2'}return sql` INSERT INTO user ${sql.insert(dataToInsert)}`
const dataToInsert = { userName: 'test', passWord: 'test2'}return sql` INSERT INTO user ${sql.insert(dataToInsert)}`