Attach working, detach not working


#1

Hey,

I’ve created a couple of endpoints to attach/detach rows on a pivot table. Attach is working fine but Detach is not.

For example; This code works

	let order = await Order.find( params.order_id )
	order.tags().attach( [ params.tag_id ] )

This code does not work

	let order = await Order.find( params.order_id )
	order.tags().detach( [ params.tag_id ] )

Having peeked at the code the value of this._existingPivotInstances appears to be empty but I am not sure I am understanding it correctly.

Can anybody please advise? Is it a silly mistake on my behalf?

Many thanks.


#2

You have to await attach and detach function calls


#3

Doh! Thanks @virk, silly mistake.