Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Cargo

From EmissaryFGC
Revision as of 19:02, 11 May 2024 by dustloop>Alistair3149 (Created page with "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 --- @...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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
MediaWiki Appliance - Powered by TurnKey Linux