Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert() with typescript #6066

Open
kandarp-codingscape opened this issue May 2, 2024 · 0 comments
Open

insert() with typescript #6066

kandarp-codingscape opened this issue May 2, 2024 · 0 comments

Comments

@kandarp-codingscape
Copy link

kandarp-codingscape commented May 2, 2024

Hello,
I'm new to Knex, and using typescript, and the following works:
knex.select().from<User>('tbl_user').first();
where Knex is able to map columns to the User interface.

I'm trying to do same with .insert() but a bunch of tries haven't worked out.
I've tried things like:

knex.insert(user).into<User>('tbl_user');
knex<User>('tbl_user').insert(user);

User has firstName and table has first_name. Searching other issues/docs and online. Can someone help/point me in the right direction?
Thanks!

Edit: I suppose this would've worked: https://knexjs.org/guide/#postprocessresponse but ended up using https://github.com/Kequc/knex-stringcase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant