Clone
5
ttcQuery
Emma Short edited this page 2024-06-11 01:12:31 -07:00

ttcQuery is a custom query language that is standard for use in TTC. The concept is that you should be able to write a query in nearly any text box - search, template, value - and when the page is rendered, it displays that query. Searches will run the query and render the results in a list template.

Syntax

Start query: ?

  • by default, queries search the current publication
  • you can specify a publication by following this with the name, by default it will use the latest release of a publication
  • you can specify the version by including it in a pair of square brackets

Query current object: ^

  • refers specifically to the object based off of this specific type

Query relative object: $

  • refers to the last relative object in the hierarchy

Access child: .

  • this also maps over all items in a list and returns a list of the relevant children
  • if the parent is a list, it will return a list of just the specified child

Select: []

  • Selects any of the items that matches the provided selector
  • Providing a number selects the ordinal item in the list
  • Providing a comparator selects items that match the comparator
  • Selectors can be separated by either commas for "and" or slashes for "or", but not both

Comparators:

  • = is similar to
  • == is exactly the same
  • > greater than
  • < less than
  • >= greater than or equal to
  • <= less than or equal to
  • !! is true/exists. When used as the name of a child, it treats the entire parent as a list and resolves as a new object with the children key and value for each child
  • ! is not
  • / or, allows matching one or more comparators at the same time

Combiner: ()

  • Will only select items that match all of the selectors
  • Selectors can be separated by either commas for "and" or slashes for "or", but not both

Inline Templating insertion: {{}}

  • Allows for queries to be wrapped in a templated string
  • Can be either a direct query or used in combination with the "_" character to reference a single query single query: <<?
  • Used the same as start query, but appended to the end of a templated string
  • Used in conjunction with _ to reference the queried value query reference: _
  • used in conjunction with single query to reference the queried value separator: ::;;
  • used at the end of a template to indicate how to separate results when the results are more than one.
  • Whatever text is placed between in the middle is treated as the full separator, or in other words, if the separator doesn't have any spaces, then there will be no spaces between items in the final text
  • If no separator is provided, it will default to comma and space separation
  • placed at the end of the template but before the single query
  • should support any standard escaped characters such as newline

Examples: ?core.weapon_abilities[name=Rapid Fire].body

  • this searches the publication 'core' object for weapon_abilities that have the name ?core[v1].weapon_abilities[name=Rapid Fire].body
  • this searches version 'v1' of the publication 'core' object for weapon_abilities that have the name Sustained Hits {{?^sustained_hits}}
  • This formats the string with the queried values, which start the query within the same object that the field exists in. This would result in the string 'Sustained Hits 1' Anti-{{_.keyword}} {{_.value}}<<?^anti_abilities
  • This formats the string with the queried values, which start the query within the same object that the field exists in. This would result in the string 'Anti-Infantry 2+' or 'Anti-Infantry 2+, Anti-Monster 4+' if there are more than one matching values Anti-{{_.keyword}} {{_.value}}:://;;<<?^anti_abilities
  • This formats the string with the queried values, which start the query within the same object that the field exists in. This would result in the string 'Anti-Infantry 2+' or 'Anti-Infantry 2+//Anti-Monster 4+' if there are more than one matching values