在我的桌子上复制数据有问题

时间:2018-04-28 11:33:06

标签: javascript node.js postgresql sequelize.js

我遇到了在桌面上复制数据的问题 例如,我有这个数据

let data = [{ name: Tope},{ name: Wale},{ name: Tope}];

  models.sequelize.Promise.map(data, pValue => {
    return models.User.findOrCreate({
      where: {
        name: pValue.name,
      },
      defaults: {
        name: pValue.name,
        organization_id: req.user.org_id
      }
    }).then(result => {
      let resultData = result[0], 
          created = result[1]; // i am getting true 3x
        console.log(created);
        console.log(resultData.get());
    })
  });

我使用过这个链接,但这个流程对我不起作用 Node + Sequelize: How to check if item exists before adding? (async confusion)

0 个答案:

没有答案