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
Post a Comment