Module:CargoQuery/doc
This is the documentation page for Module:CargoQuery
This module lets you get around the |no html
bug that Cargo has by avoiding |format=template. This module implicitly assumed you ARE using named args in your template (corresponding to |named_args=yes
; you do not need to specify this.)
Unlike |format=template
, this wrapper will NOT rename parameters with underscores in them to use spaces instead.
Parameters[edit]
- You may specify all parameters the same as if they were parameters in
#cargo_query
.
Example[edit]
{{#invoke:CargoQuery|main |table=Teams,Tenures=Ten |join on=Teams._pageName=Ten.Team |where=Teams.Region="Europe" AND Ten._pageName IS NOT NULL AND Ten.IsCurrent = "1" |fields=Teams._pageName=Page |template=User:RheingoldRiver/cargo query example/template |intro={{(!}} class="wikitable" |outro={{!)}} |limit=100 }}
One-To-Many[edit]
!!! This is OPTIONAL functionality. You can ignore this entire section !!!
This template allows for one-to-many support, allowing you to specify a field to treat equivalently to a List of ...
field. Syntax is as follows:
|one_to_many=
, a list of fields you want concatenated together.|one_to_many_group=
, the thing you want our one-to-many values grouped by. UNLIKE the|group by=
parameter, this should be the FINAL name of a field, so something on the RIGHT SIDE of the equals sign in your|fields=
parameter.|one_to_many_sep=
, defaults to comma. Currently you must pick the same separator for all of your one-to-many fields.
Example[edit]
{{#invoke:CargoQuery|main |table=Teams,Tenures=Ten |join on=Teams._pageName=Ten.Team |where=Teams.Region="Europe" AND Ten._pageName IS NOT NULL AND Ten.IsCurrent = "1" |fields=Teams._pageName=Page |one_to_many=Ten.Player=IDs |one_to_many_group=Page |one_to_many_sep=, |template=User:RheingoldRiver/cargo query example/template |intro={{(!}} class="wikitable" |outro={{!)}} |limit=100 }}
Here, the one_to_many
is a list of players on the team in question. For each ONE team, there are MANY players, so the field IDs
that's sent to the template is a comma-separated list of players, grouped by team page.
What does one-to-many mean?[edit]
If you've made a table with a List of _
-type field, you've already made a one-to-many relationship. The object of the table, the entity that all of the columns/fields describe, is the ONE; and each item in the list is the MANY.
But list-type fields only allow for single-attribute MANY objects: if you have |Team= TeamName |Roster= Player1, Player2, Player3
then you can't also put the players' positions into the Roster list. In situations where there's a bunch of different attributes you care about in the MANY, the MANY will have its own table. But given built-in Cargo, this situation is pretty hard to query. So, this template provides an easy interface to accessing one-to-many relationships, which allows you to treat any property from the relationship as if it were a list-of-type field in the parent table.