SHARE
TWEET

Untitled

a guest Jun 17th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports = function(sequelize, DataTypes) {
  2. var Users = sequelize.define("Users", {
  3.     username: {
  4.       type: DataTypes.STRING,
  5.       allowNull: false,
  6.       unique: true,
  7.       validate: {
  8.         len: [1, 30]
  9.       }
  10.     },
  11.     email: {
  12.       type: DataTypes.STRING,
  13.       allowNull: false,
  14.       unique: true,
  15.       validate: {
  16.         len: [1, 100]
  17.       }
  18.     },
  19.     password: {
  20.       type: DataTypes.STRING,
  21.       required: true,
  22.       validate: {
  23.         len: [8]
  24.       }
  25.     },
  26.   });
  27.  
  28.   Users.associate = models => {
  29.     Users.hasOne(models.ProfileInfo, {foreignKey: 'id'});
  30.   }
  31.      
  32. module.exports = (sequelize, DataTypes) => {
  33.     var ProfileInfo = sequelize.define("ProfileInfo", {
  34.         name: {
  35.             type: DataTypes.STRING,
  36.             allowNull: false,
  37.             validate: {
  38.                 len: [1, 100]  
  39.             }
  40.         },
  41.         cuisine: {
  42.             type: DataTypes.STRING,
  43.             allowNull: false,
  44.             validate: {
  45.                 len: [1, 50]
  46.             }
  47.         },
  48.         description: {
  49.             type: DataTypes.STRING,
  50.             allowNull: false,
  51.             validate: {
  52.                 len: [1, 200]
  53.             }
  54.         },
  55.         address: {      
  56.             type: DataTypes.STRING,
  57.             allowNull: false,
  58.             validate: {
  59.                 len: [1, 100]
  60.             }
  61.         },
  62.         phoneNumber: {
  63.             type: DataTypes.STRING,
  64.             allowNull: false,
  65.             validate: {
  66.                 len: [1, 100]
  67.             }
  68.         },
  69.         email: {
  70.             type: DataTypes.STRING,
  71.             allowNull: false,
  72.             validate: {
  73.                 len: [1, 100]
  74.             }
  75.         }    
  76.     });
  77.  
  78.     ProfileInfo.associate = models => {
  79.         ProfileInfo.belongsTo(models.Users, {foreignKey: 'id'});
  80.     }
  81.     return ProfileInfo;
  82. };
  83.  
  84.  
  85. Right now, both of these tables are created and are working separately through the app. When a user inputs the information, it saves in the database. However, after various attempts and changes, the innerjoin to connect the profile to each user is not happening. Any help is appreciated.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top