javascript - Sequelize. How to use different value of parameters in creation -


i'm trying write create user function. have such code

   createuser: function (user) {         return db.user.create({             id: user.id,             username: user.username,             password: sha1(user.password),             first_name: user.first_name,             last_name: user.last_name,             email: user.email,             allow_password: user.allow_password         });     } 

but it's correct when fill user's fields. actually, need username , email, when put 2 parameters - i've gotten 500 server error. how can other rows implicit?

the answer: have convert password before query

createuser: function (user) {         if(user.password) {           user.password = sha1(user.password);         }         return db.user.create({             id: user.id,             username: user.username,             password: user.password,             first_name: user.first_name,             last_name: user.last_name,             email: user.email,             allow_password: user.allow_password         });     } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -