From 0c65389ebd5514fa9c11ee712dc075036ea9caa9 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Tue, 21 Jul 2020 21:18:41 +0200 Subject: [PATCH] docs(adonis): add relationship methods --- backend/adonis.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/adonis.js b/backend/adonis.js index 9110e06..7f9c9bc 100644 --- a/backend/adonis.js +++ b/backend/adonis.js @@ -277,6 +277,11 @@ instance.merge(jsonAttributes) // Modifies the specified attribute instance.save() // Save the instance to the database. instance.delete() // Delete model instance from the database. +instance.associate(id) // Exclusive to belongsTo relationship, where it associates two model instances together. +instance.dissociate(id) // The opposite of associate, where you just drop the relationship +instance.attach([id, id...]) // Works with the belongsToMany relationship to attach a relationship inside the pivot table. +instance.detach([id, id...]) // The opposite of the attach method, and it removes the relationship from the pivot table only. + /******************************************************************************************** * QUERY BUILDER * https://adonisjs.com/docs/query-builder