I am currently working on an HTML/JS App using Windows Azure Mobile Service. I have two tables, one storing information about an attraction [attractionTable(attractionId, address,...)] and one keeping track of which user likes which attraction [favoriteAttractionTable(attractionId, userId, fav(bool))].
If the client wants to have a list of his favorite attractions there should only be one request to the server. On the server side I edited the read script of the favoriteAttractionTable to this:
function read(query, user, request) {
var sql =
"FROM routesTable rt, favoriteAttractionTable ft " +
"WHERE rt.id = ft.routeId;";
mssql.query(sql, {
success: function(results) {
request.respond(statusCodes.OK, results);
}});
}
In my JavaScript Code I am using the following request
function loadFavoriteAttractions(){
favTable = client.getTable("favoriteAttractionTable");
var query = favTable.where({
fav: true,
userId : 0
}).read().done(function (results) {
console.log(results);
}, function (err) {
alert("Error: " + err);
});
}
I basically get the information of all attractions that any user has added to his favorites but I want to modify the var sql in a way to receive only the ones related to the appropriate userId.
query.getComponents();
shows queryString: '((fav eq true) and (userId eq 0))' in my server script. But I am wondering how I can access this information?!
request.parameters.fav
is supposedly undefined.
Any advice is highly appreciated :)