ORM-21: Implement BelongsToMany (read side) #21
Labels
No labels
area:core
area:database
area:migrations
area:model
area:relations
area:schema
area:tests
breaking-change
size:M
size:S
tracking
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
NoctisWolfshadow/tessera-orm#21
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Depends on: #18
Context
Many-to-many goes through a pivot table. To avoid joins and a pivot
Model, the relation is expressed as anIN (subquery)filter on the other model, built with the already-publicExpression::new. Both sides declare the relation, with the key names swapped.Tasks
BelongsToMany::<A, B>::new(pivot, local_key, foreign_key), const-constructible..of(&a)returns a handle whosequery() -> Query<B>carries<B pk> IN (SELECT <foreign_key> FROM <pivot> WHERE <local_key> = ?). Same delegating methods as #19.post.tags()andtag.posts().Example
SQL for the call above:
Acceptance criteria
post.tags()andtag.posts()) return the right rows.filter,order_byandlimit.Vec.attach,detachandsyncfor many-to-many #22load_for) to avoid N+1 queries #23