Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: createDB Arguments: server Description: Page type: webl Render function: Module: demavu Page source: var db = Wub_GetDB("demavu"); var coll = Wub_GetCollection(db, "data"); var data = WubCall("data", ["-"]); server = Str_Trim(server); var recurseData = fun(token, d) var res = []; if Type(d) == "list" then var i = 1; every l in d do res = res + recurseData(token + "," + ToString(i), l); i = i + 1 end; elsif Type(d) == "object" then every o in ToList(d) do res = res + recurseData(token + "," + o, d[o]) end; elsif Type(d) == "string" then var o = [. .]; o[token] := d; res = [o] else res = [[. "Unknown Type" = d .]] end; return res end; var s = recurseData("sXbxqn7udYfN", data); var res = []; every dat in s do var path = ToList(dat)[0]; var Path = Str_Split(path, ","); var value = dat[path]; var i = 0; var obj = [. .]; every p in Path do obj["lev" + ToString(i)] := Str_Trim(p); i = i + 1 end; obj["value"] := value; obj["server"] := server; res = res + [obj] end; // reset all the data var queryObj = Wub_NewDBObject([. "server"=server .]); Wub_RemoveDB(coll, queryObj); every r in res do var dbobj = Wub_NewDBObject( r ); Wub_InsertDB(coll, dbobj); end; Size(res); /* var queryObj = Wub_NewDBObject([. "app"="devtools" .]); Wub_RemoveDB(coll, queryObj); var dbobj = Wub_NewDBObject([. "app"="devtools", selected=game.]); Wub_InsertDB(coll, dbobj); */