1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-12-18 08:34:06 +00:00

docs(adonis): add callback to attach method

This commit is contained in:
Julien Le Coupanec 2020-07-22 10:07:50 +02:00
parent 9025748f03
commit 62efe852d1

View File

@ -277,10 +277,10 @@ instance.merge(jsonAttributes) // Modifies the specified attribute
instance.save() // Save the instance to the database. instance.save() // Save the instance to the database.
instance.delete() // Delete model instance from 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.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.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.attach(arrayOfIds, callback) // Works with the belongsToMany relationship to attach a relationship inside the pivot table. The attach method accepts an optional callback receiving the pivotModel instance, allowing you to set extra properties on a pivot table if required:
instance.detach([id, id...]) // The opposite of the attach method, and it removes the relationship from the pivot table only. instance.detach(arrayOfIds) // The opposite of the attach method, and it removes the relationship from the pivot table only.
/******************************************************************************************** /********************************************************************************************
* QUERY BUILDER * QUERY BUILDER