Publishes a notification when an associated record is removed to a model's collection. For example, if a
User model has an association with the
Pet model so that a user can have one or more pets available in its
pets attribute, then any time a pet is removed from a user's
publishRemove may be called.
|Description||Accepted Data Types||Required ?|
|1||ID of Updated Record||
|2||Attribute of associated collection||
|3||ID of associated record that was removed||
publishRemove() emits a socket message using the model identity as the event name. The message is broadcast to all sockets subscribed to the model instance via the
.subscribe model method.
The socket message is an object with the following properties:
- id - the
idattribute of the model instance
- verb -
- attribute - the name of the model attribute that was removed from
- removedId - the ID of the record that was removed
If this argument is included then the socket attached to that request will not receive the notification.
See the documentation for
publishUpdate for information about
options.noReverse. In general, you should not have to set this argument unless you are writing your own implementation of
publishRemove for a model.
Is something missing?
If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.
- Blueprint API
- Command Line Interface
- Response (`res`)
- Waterline (ORM)
- Resourceful PubSub
- Socket Client
We wrote a book!
Get early access to the book
with promotion code: mcneildoc