It looks like you're new here. If you want to get involved, click one of these buttons!
using System; using iKnode.Applications; using iKnode.Applications.Data; using System.Collections.Generic; namespace Applications { [Application] public class ScoreManage : BasePackage { private const string CollectionName = "scoreCollection"; public List<Document> getScore(){ return this.Repository.QueryCollection(CollectionName,"{}","id","asc",0,10).List; } public void addScore(string name, string score){ var date = DateTime.Now.ToString(); var doc = new Document(CollectionName); doc["name"] = name; doc["score"] = score; doc["date"] = date; this.Repository.Save(doc); } } } |
local iKnodeService = iKnodeSdk.ApplicationClient( {userId = "MY_ID", apiKey = "MY_API_KEY", appName = "ScoreManage"} --My App Name ) --[[ This is an example of a callback function. *<a href="http://forum.giderosmobile.com/profile/param" rel="nofollow">@param</a> data: it's what is going to be returned from the service. ]]-- getScoreCallback = function(data) local scores = data if (type(scores) == "table") then print("table") printTable(scores) else if (type(scores) ~= "function") then print(scores) end end return scores end --This just prints the table recieved by iknode. --Here we create the function that will call the iKnodeService and retrieve the Scores. function getScores() return iKnodeService:execute({ methodName = "getScore", callback = getScoreCallback }) end --Here we create the function that will call the iKnodeService and will add score. function addScore(name, score) iKnodeService:execute({ methodName = "addScore", parameters = { name=name, score=score } }) end --Just a simple recursive function to print the table. function printTable(tb) for i,v in pairs(tb) do if (type(v) == "table") then printTable(v) else print(i..":"..v) end end end --As simple as this, you can get the stored scores by just calling a function. local scores = getScores(); --Also with add score. addScore("Iwasaddedfromgideros","100") |
Likes: fxone