Snippets
Last updated
Last updated
Copy and Paste are a big part of composing database queries. Because it’s much easier to duplicate prior work than to write it from scratch. This is particularly true for common JOIN
statements or complex CASE
expressions. As your list of queries in TONalytica grows, however, it can be difficult to remember which queries contain the statement you need right now. Enter Query Snippets.
Query Snippets are segments of queries that your whole team can share and trigger via auto-complete. You create them at Settings
-> Query Snippets
.
${1:table}
is an insertion point with placeholder text. When TONalytica renders the snippet, the dollar sign $
and curly braces {}
will be stripped away and the word table
will be highlighted for the user to replace.
You can use the placeholder text as a desirable default value for the user to override at runtime.
You designate insertion points by wrapping an integer tab order with a single dollar sign and curly braces ${}
. A text placeholder preceded by a colon :
is optional but useful for users unfamiliar with your snippet.
The text insertion carat will jump to the second line between the quote marks ''
. When the user presses Tab
the carat will jump backwards onto the first line. When the user presses Tab
again, the carat will jump to the third line and this_date
will be highlighted to prompt the user for the desired value.
An insertion point of zero ${0}
is always the last point in the tab order.
If you have Live AutoComplete enabled, you can invoke your snippet from the Query Editor by typing the trigger word you defined in the Query Snippet editor. Auto Complete will suggest it like any other keyword in your database.
Here are some other ideas for snippets:
Frequent JOIN
statements
Complicated clauses like WITH
or CASE
.