question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating relations without Id field

See original GitHub issue

My backend doesn’t return the ids of the relations out of the box.

This should work:

color: this.hasOne(Color, 'color'),

It should fetch the relation from the color.id field.

Current behavior is that it’s simply not working.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
kevratcommented, May 9, 2019

Thanks, it works! I removed the sportsman_id from the schema, but left the sportsman_id as a foreign key in the model. That way, I can get the associated data from the server and then request it from orm as if it were in the schema. Maybe add a few words about this in the documentation? I think it should be closed

0reactions
creauxcommented, May 4, 2021

I think this should be in the documentation! It was a bit of pain to find it 🥇

Read more comments on GitHub >

github_iconTop Results From Across the Web

One-to-many relationship without column that represent "one"
1. If you don't want to add the groupId to the Address table then yes, you can certainly just create a new table...
Read more >
Relationship with a table without unique/primary key
I can't create this relationship because SubWorks.subWorkName is not an unique key (or primary key, it just don't appear in phpMyAdmin) and it ......
Read more >
How to create relationships on non id fields is not clear #215
Another solution (at least a partial one) is to add a local id field to relation/immutableRelation decorator. See @esbenp's thread here: #219 — ......
Read more >
Help with relationships without using Id... - Microsoft Q&A
Please help on how to form a relationship correctly. I have 2 tables with many fields, one contains users, the other a list...
Read more >
Relations (Reference) - Prisma
The scalar authorId field, which is referenced by the @relation attribute. This field does exist in the database - it is the foreign...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found