Module:Cargo

local p = {}

function p.query( frame ) local results = mw.ext.cargo.query( frame.args.tables, frame.args.fields, {       where = frame.args.where,        join = frame.args.join,        groupBy = frame.args.groupBy,        having = frame.args.having,        orderBy = frame.args.orderBy,        limit = frame.args.limit,        offset = frame.args.offset,    } ) local out if #results > 0 then out = frame.args.intro or '' for index = 1, #results, 1 do           out = out .. '\n' .. frame:expandTemplate{ title = frame.args.template, args = results[index] } end out = out .. '\n' .. ( frame.args.outro or '' ) else out = frame.args.default or '' end

if frame.args.debug == "yes" then out = out .. "\n\n" .. frame.args.where .. "\n\nResults: " .. #results end return out end return p