Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: cleanRecord Arguments: printOrDelete Description: Takes the OPT fields and removes all records that match. Use with caution! Page type: webl Render function: Module: demavu Page source: var s = "Querying " + ToString(OPTIONALARGS) + "\n\n"; var db = Wub_GetDB("demavu"); var coll = Wub_GetCollection(db, "data"); var search = [. .]; var i = 0; while i < Size(OPTIONALARGS) do var f = OPTIONALARGS[i]; var v = OPTIONALARGS[i+1]; search[f] := v; i = i + 2 end; if OPTIONALARGS != [] then var searchDB = Wub_NewDBObject(search); every o in Wub_QueryDB(coll, searchDB,-1) do if printOrDelete == "print" then s = s + ToString(o) + "\n" elsif printOrDelete == "delete" then DeleteField(o, "_id"); var removeObj = Wub_NewDBObject(o); Wub_RemoveDB(coll, removeObj); s = s + "REMOVED " + ToString(o) + "\n"; else s = printOrDelete + " NOT A LEGAL ARGUMENT: use 'print' or 'delete'"; end end else s = "NO arguments to search for" end; s;