Pergunta

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?

Foi útil?

Solução

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] });
        }
    });
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top