View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page



Returns an array of sockets that are subscribed to record. This can be used in conjunction with lower-level methods like sails.sockets.emit to send custom messages to a collection of sockets, or with .subscribe to subscribe one group of sockets to a new instance.

Description Accepted Data Types Required ?
1 Record , , Yes
2 Contexts to subscribe to , No

Note: record can be either an instance of a model, or a model’s primary key.


If you specify a specific context (or array of contexts), you will only get sockets that are subscribed to the specified contexts for the record.

Example Usage

Controller Code

// Find user #1
        // Get all of the sockets that are subscribed to user #1
        var subscribers = User.subscribers(userOne);
        // Subscribe them all to userOne's best friend, too
        _.each(subscribers, function(subscriber) {
           User.subscribe(subscriber, userOne.bestFriendId);

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.


We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book