Modul:SK/Query
< Modul:SK
Script error: The function "nonexistent" does not exist.
--------------------------------------------------------------------
-- Modul:SK/Query
--------------------------------------------------------------------
local q = {}
local db = require("Modul:SK").db
function q.by_prefix(prefix)
local out = {}
for code, d in pairs(db) do
if code:sub(1, #prefix) == prefix then
out[#out+1] = { code = code, naziv = d.naziv }
end
end
table.sort(out, function(a,b) return a.naziv < b.naziv end)
return out
end
function q.by_name_substring(substr)
substr = mw.ustring.lower(substr or "")
local out = {}
for code, d in pairs(db) do
if mw.ustring.find(mw.ustring.lower(d.naziv), substr, 1, true) then
out[#out+1] = { code = code, naziv = d.naziv }
end
end
table.sort(out, function(a,b) return a.naziv < b.naziv end)
return out
end
return q