* Un-associate one or more instance(s). * * @param {Model} sourceInstance instance to un associate instances with * @param {Model|Model[]|string|string[]|number|number[]} [oldAssociatedObjects] Can be an Instance or its primary key, or a mixed array of instances and primary keys * @param
(sourceInstance, oldAssociatedObjects, options)
| 762 | * @returns {Promise} |
| 763 | */ |
| 764 | remove(sourceInstance, oldAssociatedObjects, options) { |
| 765 | const association = this; |
| 766 | |
| 767 | options = options || {}; |
| 768 | |
| 769 | oldAssociatedObjects = association.toInstanceArray(oldAssociatedObjects); |
| 770 | |
| 771 | const where = { |
| 772 | [association.identifier]: sourceInstance.get(association.sourceKey), |
| 773 | [association.foreignIdentifier]: oldAssociatedObjects.map(newInstance => newInstance.get(association.targetKey)) |
| 774 | }; |
| 775 | |
| 776 | return association.through.model.destroy({ ...options, where }); |
| 777 | } |
| 778 | |
| 779 | /** |
| 780 | * Create a new instance of the associated model and associate it with this. |
nothing calls this directly
no test coverage detected