Learn the basics of queries, the syntax and how to reference sources
{}
. These blocks can contain any logic you need, and they can be used
to modify the query, add conditions, or even create loops.
Before sending the query to the database, Latitude compiles the logic in your query, and then sends the compiled query to the database. Your database will never
see the logic, only the final query. This means that Latitude logic is compatible with any supported source type.
Logic blocks can be used for:
\{
so that Latitude does not interpret them as logic blocks.In the same note, curly brackets inside strings will not be treated as logic blocks. If you need to use curly brackets inside a string, you must escape the quotes with a backslash \'
.{variable_name = value or expression}
{expression}
.
SELECT * FROM users WHERE name = $1 AND age > $2 AND created_at > $3
And we send the values to your database separately:
$1: 'Latitude'
$2: 18
$3: '2021-01-01'
How the actual reference looks like depends on your source type, all of them are compatible with this feature. This is a security measure to prevent
SQL injection and other vulnerabilities.
If you need to insert a value directly into the query bypassing this parameterization, you can use the interpolate
function. Read more about
it in the Interpolation section.
--debug
option. Learn more about it in the CLI documentation.{#if}
and {#each}
blocks. These blocks will decide
whether to include or exclude a part of the query based on the condition.
{@config}
block.