1

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.

Community
  • 1
  • 1
Aravinth
  • 397
  • 1
  • 4
  • 19

1 Answers1

0

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

tcruz
  • 1
  • 1
  • Hi tcruz ,Thanks for response. I want to publish associated populated collection fields, I also used that code. but , that doesn't fire associated collection. – Aravinth Jun 27 '15 at 04:51