Pregunta

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
 }
¿Fue útil?

Solución

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!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top