Delete the record specified by id
from the database forever and notify subscribed sockets.
DELETE /:model/:id
This destroys the record that matches the id parameter and responds with a JSON dictionary representing the destroyed instance. If no model instance exists matching the specified id, a 404
is returned.
Additionally, a destroy
event will be published to all sockets subscribed to the record room, and all sockets currently subscribed to the record will be unsubscribed from it.
Parameter | Type | Details |
---|---|---|
model | The identity of the containing model. e.g. 'purchase' (in /purchase/7 ) |
|
id (required) |
The primary key value of the record to destroy, specified in the path. e.g. '7' (in /purchase/7 ) . |
Delete Pinkie Pie:
DELETE /user/4
{
"name": "Pinkie Pie",
"hobby": "kickin",
"id": 4,
"createdAt": 1485550644076,
"updatedAt": 1485550644076
}
If you have WebSockets enabled for your app, then every client subscribed to the destroyed record will receive a notification where the event name is that of the model identity (e.g. user
), and the “message” has the following format:
verb: 'destroyed',
id: <the record primary key>,
previous: <a dictionary of the attribute values of the destroyed record (including populated associations)>
For instance, continuing the example above, all clients subscribed to User
#4 (except for the client making the request) might receive the following message:
id: 4,
verb: 'destroyed',
previous: {
name: 'Pinkie Pie',
hobby: 'kickin',
createdAt: 1485550644076,
updatedAt: 1485550644076
}
If the destroyed record had any links to other records, there might be some additional notifications:
Assuming the record being destroyed in our example had an association with a via
, then either updated
or removedFrom
notifications would also be sent to any clients who are subscribed to those child records on the other side of the relationship. See Blueprints > remove from and Blueprints > update for more info about the structure of those notifications.
If the association pointed at by the
via
is plural (e.g.cashiers
), then theremovedFrom
notification will be sent. Otherwise, if thevia
points at a singular association (e.g.cashier
) then theupdated
notification will be sent.