Template:Query

Revision as of 03:40, 16 July 2023 by Saucy (talk | contribs) (Simpler way to query Cargo)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Error: Table null not found.

Documentation

This template does a simple query for data from a Cargo table. It returns data from one column of one table, by filtering one other column. This is all that is needed for many of the uses of Cargo on this wiki, but for more complex uses, you'll need to use the Cargo functions directly.

Usage

Basic usage:

{{query|table=table|get=column to output data from|from=name or ID}}

or

{{query|table=table|get=column to output data from|filter_col=column to filter|filter_col_val=value to filter by}}

  • |table= - The Cargo table to search in. Go to Special:CargoTables to see all tables.
  • |get= - The table column from which data should be retrieved and output.
  • |from= - If this parameter is a valid Discord ID (e.g. 501310750074077215), then data will only be taken from table rows whose "id" column matches this parameter. If this parameter is not a valid Discord ID, then the "name" column will be searched instead. If these columns are not present in the table, or you just want to filter by a different column, then use these parameters instead:
    • |filter_col= - The column to search. If using this parameter, you must also specify the filter_col_val parameter.
    • |filter_col_val= - The value to search for in the column specified in filter_col.

Not all parameters were listed here. For a detailed description of all parameters, see the TemplateData section below.

Examples

If you want to output the owner of Whenthe, you could use either {{query|table=discord_servers|get=owner|from=Whenthe}} or {{query|table=discord_servers|get=owner|from=501310750074077215}}, which would output: steely21More...

If you wanted a list of active servers, you could do something like {{query|table=discord_servers|get=name|filter_col=status|filter_col_val=active|limit=25}}, which would output: 69SwagBalls420, 69SwagBalls420, Arabfunny III, Bruh Irony 3: the return of the skibidi toilets, Bruhmoment, CATS IN A TUXEDO, Dogelore, Dogelore Refugee Ark, 𝓓𝓕𝓜, Epic Sad Bunch, Gondal.gay, Gondal: Thenite Republic, Holy Gondal Empire/arz, Holy Gondal Empire/en, Holy Gondal Empire/es, Holy Gondal Empire/he, House of Bingus, I.C.U., iorny heaven CHAPTER 3, Irony Server Wiki Discord, Latvian OKBR, Loser Island, OkBhaiBudbak, OkBuddyChicanery, okbuddyhololiveMore...

TemplateData

Does a simple query for data from a Cargo table. It returns data from one column of one table, by filtering one other column.

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
Tabletable

The Cargo table to search in. Go to [[Special:CargoTables]] to see all tables.

Example
discord_servers
Stringrequired
Field to displayget

The table column from which data should be retrieved and output. For example, if you wanted to find and output Whenthe's status, you would put the "status" column here.

Example
status
Stringrequired
Fromfrom

Filters results by name or ID. If this is in the format of a Discord ID, then only results whose "id" column matches this parameter will be used. Otherwise, only results whose "name" column matches this parameter will be used. For example, if you wanted to find and output Whenthe's status, you would put Whenthe's name or ID here. If there's a different column you want to filter by, you can use the filter_col and filter_col_val parameters instead.

Example
Whenthe
Stringsuggested
filter_colfilter_col

The table column that contains the values you want to filter. If using this parameter, the "from" parameter will be ignored, and you MUST also use the filter_col_by parameter.

Example
name
Stringoptional
filter_col_valfilter_col_val

The value you're searching for from the column defined in the filter_col parameter. Only the data from rows that match this value in the column will be used. This parameter has no effect if filter_col is not defined.

Example
Whenthe
Stringoptional
limitlimit

The maximum number of results to get. Many queries only have one result. If there is more, and this parameter is set to a number greater than the default 1, the results will be output in a comma-delimited list.

Default
1
Numberoptional
defaultdefault

What to output if no results are found.

Default
(empty string)
Stringoptional
has_htmlhas_html

Set this to "yes" if the output you want contains HTML that you want to use.

Booleanoptional