I'm tired of these callback trees in azure mobile services. So I would like to wrap things like mssql.query(sql, params, options) with the help of a promise library like Kris Kowal's Q. In that way it would be very easy to get fulfillments via the then function.
Currently I don't succeed in doing this:
Error: [Error: Invalid callback options passed to 'query'. Callback options must be an object with at least one 'success' or 'error' property of type 'function' or a systemProperties property of type 'Array'.]
For core nodejs functions like fs.readFile Q.denodeify works, but I suppose this has to deal with the way the callbacks are defined. In mobile services they use an object literal with a succes and error properties just like the above error log indicates:
mssql.query(sql, sqlParams, {
success: function(results){},
error: function(){}
});
While in core nodejs the readfile function expects a callback like the following:
fs.readFile('./Index.html', function read(err, data) {}*)
If someone managed to get this to work or has a better solution to avoid the pyramid of callbacks in mobile services, just let me know.