Question

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
 }
Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top