i'm totally new to sails association. i want to publish (publishCreate and publishUpdate) socket events in associated collection.
i got one solution on Sails publish(Update) system does not propagate to associations my code is like
module.exports = {
attributes: {
title: 'string',
owner:{
model:'user'
}
},
afterUpdate: function(post, cb){
User.publishUpdate(post.owner, {/* props you want to send */});
cb();
}
};
But it does not work for me.
you have to subscribe to this model using the .subscribe() method to receive the message, check the docs: http://sailsjs.org/#!/documentation/reference/websockets/resourceful-pubsub/publishUpdate.html