[Node.js][Mobile Apps] Help with table.insert with EasyTables RRS feed

  • Question

  • Hi all,

    I have developed a mobile app that uses the AppService REST api to read and insert data into a Easy Table defined in the Azure portal. This works really well and was an easy task to develop. However, now i need to override the basic insert function in the javascript back-end to do some extra server-side work.

    My app uses the Easy Table to store a leaderboard with some data (a username and several scores associated with it). What i need to do now is to extend the insert behavior so that only one record for a given username is present in the table and then update its scores only if the new ones are better than the older ones.

    So in table.insert() I want to:

    1) Query the table to know if context.item.UserName is already inserted into the table

    2) If the item is not present then insert it, else update the record only for the columns whose the score value is better

    Can't find any examples anywhere on how to do such simple things, no code examples at all and no api reference. My insert function: MyFile.js 

    var table = module.exports = require('azure-mobile-apps').table();
    table.insert(function (context) {
       // Query the table for "UserName" (context) {
       // add an additional query operator
       context.query.where({ UserName:  context.item.UserName });              
       return context.execute();

    I'm stuck here because there is no documentation at all :( Can someone please give me an hand on this?

    Thank you very much in advance!! ;)

    Tuesday, February 23, 2016 5:18 PM


All replies