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

Composite key considerations #50

Open
jellelicht opened this issue May 3, 2022 · 1 comment
Open

Composite key considerations #50

jellelicht opened this issue May 3, 2022 · 1 comment

Comments

@jellelicht
Copy link

Issue type:

[x] Question

Database system/driver:

[x] Postgres

typed-knex version:

[x] latest
Knex.js version: 1.0.4

Steps to reproduce or a small repository showing the problem:

Very simple question, but how would I represent composite keys in typed-knex?

From a glance at the source code, it seems this is not supported; my more pressing question is whether things will just work out if I don't annotate any columns as primary key for those tables that only have a composite key?

Obviously stuff like findByPrimaryKey won't work in that case, which is totally fine as my code obviously doesn't use that right now 😄

@wwwouter
Copy link
Owner

wwwouter commented May 4, 2022

Yeah, you're correct, findByPrimaryKey works when there is only one column. Only *ByPrimaryKey functions use the primary key annotation, so using other functions will work with your composite key.

I think the *ByPrimaryKey functions are a bit too much ORM-like and maybe were a mistake. My plan is to move a bit closer to Knex, being a querybuilder, and move away from ORM-like functionality.

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

2 participants