Friday, November 8

Tag: mysql-workbench

Stored Procedure for node.js

more
User.createuser = (req, result) => { sql.query("INSERT INTO Users SET ?", req, (err, res) => { if (err) { console.log("error: ", err); result(err, null); return; } // if (await User.findOne({ where: { username: req.body.username } })) { // throw 'Username "' + req.body.username + '" is already taken'; // } console.log("created User: ", { id: res.insertId, ...req }); result(null, { id: res.insertId, ...req }); }); }; Example json object for api create route (post method) { "username": "seve", "user_name": "sev123", "user_surname": "avcı", "email": "sevre@gmail.com", "user_type": "user", "password": "123456" } The "I...