Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: printDB Arguments: Description: Page type: webl Render function: Module: demavu Page source: var db = Wub_GetDB("demavu"); var coll = Wub_GetCollection(db, "data"); var query = [. .]; if Size(OPTIONALARGS) > 0 then query["server"] := OPTIONALARGS[0] end; var queryObj = Wub_NewDBObject(query); var objs = Wub_QueryDB(coll, queryObj, 50000); var orderFields = fun(obj) var s = [. .]; if "server" member obj then s = [. "server" = obj["server"] .]; DeleteField(obj, "server") end; every f in Sort(ToList(obj), fun(a, b) if a > b then 1 elsif a == b then 0 else -1 end end) do s[f] := obj[f] end; return s end; var s = "[ "; every obj in objs do DeleteField(obj, "_id"); var val = obj.value ? ""; if Stringp(val) and val != "" then obj.value := Wub_ReplaceAll(val, `"`, "'"); end; s = s + ToString(orderFields(obj)) + ",\n"; end; if Size(s) > 2 then s = Select(s, 0, Size(s)-2) end; s + " ];\n";