I am trying to create a custom API for Azure Mobile Services that does a Transact-SQL command on the table. According to the docs I should be able to use an object called 'mssql' to do this (http://msdn.microsoft.com/en-us/library/jj554212.aspx). However, the object does not seem to exist and my backend script always fails with error 500 (internal server error). Does this object not exist in custom API backend scripts?

有帮助吗?

解决方案

To use that object in a custom API, you should access it via the request object passed to the API:

exports.get = function(request, response) {
    var mssql = request.services.mssql;
    mssql.query('select GETDATE() from myTable', {
        success: function(results) {
            response.send(200, { serverTime: results[0] });
        }
    });
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top