如何在AfterCreate中访问请求对象 - 水线,航行

时间:2015-07-24 21:02:23

标签: javascript node.js express sails.js waterline

我有两个模型Newspaper.js和Reader.js

// Newspaper
module.exports = {

  attributes: {

    title: {
      type: 'string'
    },
  }
};

和读者

//Reader
module.exports = {

  attributes: {

    // In case if the message is poll, it has options field which enumerates choices.
    title: {
      type: 'string'
    },
  }
};

一个存储多对多关系的模型

module.exports = {
  attributes: {
    newsPaper: {
      model: 'newsPaper'
    },
    reader: {
      model: 'reader'
    }
  }
};

当新读者加入多个订阅时,我的客户端会给我打电话,我会在通话中收到新闻报道。

我在afterValidate调用读者后列出了新闻报道,但没有创建读者ID。我获得了在AfterCreate中创建但没有报纸的新读者的ID。

如何在创建读者条目后创建关系?

0 个答案:

没有答案