Jaguar-dart/jaguar_orm

Manage association with object and not foreign key

jaumard opened this issue ยท 5 comments

I always find it weird that for one-to-many we set List<Object> in one side and only int id on the other side,

As v4 is going on I propose to change to always manage association with object instead of foreign key.

The will also us to use preload to load directly the nested object.

Most ORM manage relations with objects, I think it will be better to do it.

What do you think ?

Can you give an example?

On parent side it is object. On child side, it is foreign key.

If you mean jaguar should create the foreign keys for the user instead?

That's exactly that, in some case you might want to define your own foreign key but in most cases you're interested in getting the related parent. That can be a nice addition :)

That would be perfect addition.

@jaumard any idea when this will be available?

No idea, I don't think someone is working on this so I'll say not any time soon. But PR are welcome if you're motivated to do it