1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-12-22 10:08:54 +00:00

docs(adonis): add relationship methods

This commit is contained in:
Julien Le Coupanec 2020-07-21 21:18:41 +02:00
parent f8eb132e2f
commit 0c65389ebd

View File

@ -277,6 +277,11 @@ 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.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 * QUERY BUILDER
* https://adonisjs.com/docs/query-builder * https://adonisjs.com/docs/query-builder