防止SailJS水线创建用于关联的列

时间:2016-02-26 12:25:56

标签: mysql node.js sails.js waterline

我是NodeJs / sailsJS的新手。

我有以下模特:

module.exports = {
  autoCreatedAt: false,
  autoUpdatedAt: false,
  attributes: {
      person_id: {
           type: 'integer',
           primaryKey: true,
           autoIncrement: true
      },
      user: {
           model: 'user'
      },
      person_name: {
          type: 'string',
          required: true,
          size: 128
      },
      person_birthdate: {
          type: 'date'
      },
      person_gender: {
          type: 'string',
          size: 1
      }
  }
};

用户

module.exports = {
  autoCreatedAt: false,
  autoUpdatedAt: false,
  attributes: {
      user_id: {
          type: 'integer',
          primaryKey: true,
          autoIncrement: false
      },
      person: {
          model: 'person'
      }
  }
};

它在person表中创建列user,在user表中创建列person。如何阻止这些列弹出并仍能使用水线。 C#MVC中的实体框架能够提供该功能,所以我认为可能有一种方法可以在SailsJs中实现。

1 个答案:

答案 0 :(得分:0)

尝试将此行config/models.js添加到文件migrate: 'safe'中以导出配置。 关于模型设置,您可以在此处阅读:sailsjs.org/documentation

相关问题