문제

When I tried to print out the User using console.log(user); I discovered that the id was zero. However, in the database(mysql), the user id is showing the correct value, which is the uuid.

Following is my User model

module.exports = {

  tableName : 'user',
  autoPK : false,
  attributes: {

  id: {
      type : 'string',
      unique : true,
      primaryKey : true,
      uuidv4 : true,
      columnName: 'id',
      defaultsTo : uuid.v4()
  },

  // { ..... other fields} 
}    

Following is my create function :

 User.create(userObj).done(function(err, user){
  console.log(user);   
.... // other codes
 }
도움이 되었습니까?

해결책

Ah, it looks like you uncovered a bug in the latest beta version of sails-mysql. It has now been fixed and published, so if you delete your node_modules/sails-mysql folder and npm install sails-mysql@beta you should be all set. Thanks!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top