Source: site.view [edit]
Function name: updateSessionData
Arguments: sessionKey,dateStr,round,total
Description:
Page type: webl
Render function:  
Module: sportstreak

Page source:

var db = Wub_GetDB("sportstreak");
var coll = Wub_GetCollection(db, "session");

// Create a DB Object (row) to insert into the collection.
var dbq = Wub_NewDBObject([. key=sessionKey .]);

var res = Wub_QueryDB(coll, dbq, 20); // 20 = max results

if (Size(res) == 1) then
   var newData = res[0].data;
   newData.round := ToInt(round);
   newData.total := ToInt(total);
   newData.date := dateStr;

   var upobj = Wub_NewDBObject([. "$set" = [. key=sessionKey, data=newData .] .]);
   var res = Wub_UpdateDB(coll, dbq, upobj, true, false);
   "{success: true}";

else
   "{success: false}";

end;