Skip to content

v0.31.0 — model relationships

Choose a tag to compare

@tshafer tshafer released this 11 Jul 00:49

Model relationships over the query builder: hasMany / hasOne / belongsTo / belongsToMany, with conventional foreign keys you can override. Relations are awaitable and expose .query(); Model.load(models, "posts") eager-loads with one whereIn per relation (fixes N+1). belongsToMany reads a pivot and offers attach / detach / sync. Loaded relations stay out of save() and serialize via toJSON(). No JOINs, edge-safe.

See docs/models.md#relationships.