Hello,
I've got a problem with the result of mssql.query in Azure mobile services.
When I send an sql query, the result function is called twice...
I don't understand because my sql query is an "update" and the result is empty (I do not have multiple lines of results)
For example, I have a function that send an email with a new password. The email is sent twice... I found a temp solution with an index but it's not very clean.
Can you explain this ?
Here is the code :
exports.put = function(request, response) { var mssql = request.service.mssql; //construct SQL query var email = "test@toto.com"; var password = require("crypto").randomBytes(4).toString('hex'); var password_md5 = require("crypto").createHash("md5").update(password).digest("hex"); var sql = "update dbo.mytable SET password='"+password_md5+"' where id=12"; var id = 0; //temp solution mssql.query(sql, { success: function(results) { //Send email with new pwd if(id == 0) { response.send(statusCodes.OK,password_md5); sendEmail(email,password); } id++; //temp solution }, error: function(err) { response.send(statusCodes.INTERNAL_SERVER_ERROR,"Error : " + err); } }); }
Thank you :-)
Steve
- Moved by Nina ZaekovaMicrosoft contingent staff Thursday, February 12, 2015 7:30 AM