Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: removeRecord Arguments: server,category,id Description: Page type: webl Render function: Module: demavu Page source: var db = Wub_GetDB("demavu"); var coll = Wub_GetCollection(db, "data"); if server == "-" then server = "staging" end; var selectedGame = WubCall("demavu.getConfigVar", [server,"selectedGame"]); id = Base64_Decode(id); var name = id; id = Wub_ReplaceAll(id, " ", "_"); var path = []; if category == "games" then path = ["-","games", id, "name" ] else path = ["-","games",selectedGame, category, id] end; var obj = [. .]; var ret = "OK"; var done = false; var i = 0; every o in path do if path[i] != "*" then if path[i] == "-" then if i == 0 then obj["lev" + ToString(i)] := "sXbxqn7udYfN"; elsif i == 2 then obj["lev" + ToString(i)] := selectedGame; end elsif path[i] == "selected" and i == 1 then done = selectedGame else obj["lev" + ToString(i)] := o; end end; i = i + 1 end; if done == false then var s = "---"; var queryObj = Wub_NewDBObject(obj); every o in Wub_QueryDB(coll, queryObj,-1) do DeleteField(o, "_id"); var removeObj = Wub_NewDBObject(o); Wub_RemoveDB(coll, removeObj); s = s + "REMOVED: " + ToString(o) + "\n"; end; ret = s; else ret = ToString(done) end; ret; NewPage(ret, "text/plain");