Skip to content

ManyToManyRelation Relatioship - 1 parent table 2 entries in relatioship table #2303

@codingwithswapnil

Description

@codingwithswapnil

For relation from A to B via C, we can have relation as ManyToManyRelation.

In out example, A and B table are same

relationship: {
relation: Model.ManyToManyRelation,
modelClass: ${__dirname}/A,
join: {
from: 'A.uuid',
through: {
from: 'R.item_uuid_child',
to: 'R.item_uuid_parent',
extra: [
'A_uuid_child',
'A_uuid_parent',
'relation_p_to_c',
],
},
to: 'A.uuid',
},
}

Now, in our usecase, we can have 2 entries in R table while 1 entry in A table. Will that be feasible from objection to manage? Right now, its creating another entry in table A automatically if I tries to do POST.

Appreciate your support!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions