Typing for checking column is foreign-key or not

Hi, is there any way to check if the column is foreign-key or not which return true or false by using typing. Check the example of primary-key attachment
No description
5 Replies
Elias Vinh
Elias VinhOP•4mo ago
Hi is there any help. Thanks
rphlmr âš¡
rphlmr ⚡•4mo ago
👋 not sure 🤔 Your isPrimaryColumn will not work with primary keys defined in table options and / or composite PK
rphlmr âš¡
rphlmr ⚡•4mo ago
I made https://drizzle.run/visualizer so I can tell that finding what is what is not easy 😅 What is your use case?
Elias Vinh
Elias VinhOP•4mo ago
Hi @Raphaël M (@rphlmr) ⚡ Yah thanks for replying my question, so my case is: You can see my example here, I want to write some functions for querying based on FK only, so want to force the typescript to only allow these FK key. so for the articles table, id is PK, userId is FK so for the PK we have isPrimaryKey returning type true or false , not boolean. That's why the id passed to the function is acceptable, userId is not acceptable. so I want to know which attr can check this userID is FK or not
No description
rphlmr âš¡
rphlmr ⚡•4mo ago
I don't know if it's possible because even getTableConfig (where you find what is what) has no generic for ForeignKey[]
Want results from more Discord servers?
Add your server