Documentation for this module may be created at Module:Companies/Search/doc
local getArgs = require('Module:Arguments').getArgs
local cargo = mw.ext.cargo
local limit = 100000
local CompaniesList = {}
function CompaniesList.main(frame)
local args = getArgs(frame)
local results = query( args)
if #results > 0 then
local container = mw.html.create('div'):attr('id', 'companies-search-container')
local ul = mw.html.create('ul')
for r = 1, #results do
ul:node(mw.html.create('li'):node('[[' .. results[r]._pageName .. ']]'))
end
container:node(ul)
return container
end
end
function query(args)
local whereStr = ''
if args.name then whereStr = whereStr .. (whereStr ~= '' and ' AND ' or '') .. '_pageName LIKE "%' .. args.name .. '%"' end
local tables = 'Companies'
local fields = '_pageName'
local cargoArgs = {
where = whereStr,
orderBy = '_pageName DESC',
limit = limit
}
local results = cargo.query(tables, fields, cargoArgs)
return results
end
return CompaniesList