publishcreate, publishupdate does not work on associated collection in sailsjs

283 views Asked by At

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.

1

There are 1 answers

1
tcruz On

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