More actions
Documentation for this module may be created at Module:Cargo/doc
local cargo = {}
local extCargo = mw.ext.cargo
local checkType = require( 'libraryUtil' ).checkType
--- Return the result of a Cargo query (#cargo_query)
--- TODO: Move to a shared module since this will be reused
---
--- For info on the parameters:
--- @see https://www.mediawiki.org/wiki/Extension:Cargo/Other_features#Lua_support
---
--- @param tables string The set of Cargo tables to be queried
--- @param fields string The field or set of fields to be displayed
--- @param args table Optional parameters for the query
--- @return table
function cargo.getQueryResults( tables, fields, args )
-- args are optional
args = args or {}
checkType( 'Module:Cargo/cargo.getQueryResults', 1, tables, 'string' )
checkType( 'Module:Cargo/cargo.getQueryResults', 2, fields, 'string' )
checkType( 'Module:Cargo/cargo.getQueryResults', 3, args, 'table' )
local success, results = pcall( extCargo.query, tables, fields, args )
if not success then
error( 'Failed to run cargo query at getQueryResults()')
end
mw.logObject( { tables, fields, args }, '[Cargo] Run Cargo query with the following params' )
return results
end
return cargo