简体   繁体   中英

Prevent SailJS waterline to create columns which are used for association

I am new to NodeJs/sailsJS.

I have following models:

Person

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
      }
  }
};

User

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

It creates column person in user table and column user in person table. How do I stop these columns to pop up and still be able to use waterline. Entity Framework in C# MVC is able to provide that functionality, so I think there might be a way to do it in SailsJs.

Try to add in file config/models.js this line: migrate: 'safe' to exported configuration. About model settings you can read here: sailsjs.org/documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM