forked from TryGhost/GQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Comparison Operators
Laran Evans edited this page Mar 29, 2016
·
3 revisions
| GQL | JSON | SQL | meaning |
|---|---|---|---|
: |
$eq |
= |
equals |
> |
$gt |
> |
is greater than |
>= |
$gte |
>= |
is greater than or equal to |
< |
$lt |
< |
is less than |
<= |
$lte |
<= |
is less than or equal to |
~ |
$like |
LIKE |
is like (used with % in the attribute value) |
| GQL | JSON | SQL |
|---|---|---|
published_at:>\'2016-03-04\' |
{published_at: {$gt: '2016-03-04'}} |
WHERE published_at > '2016-03-04' |
Date values can be represented as either LITERALS or STRINGS.
For example: created_at:\'2016-03-01\' and created_at:2016-03-01 are equivalent and both are valid.
Date values are supported as values via the JSON API to the extent that Knex supports them. Issues around timezones, etc. should be handled however Knex requires them to be handled.
Dates as strings can be converted to Date objects using transformers.
| GQL | JSON | SQL | Meaning |
|---|---|---|---|
foo:~%bar% |
{foo: {$like: '%bar%'}} |
WHERE foo LIKE '%bar%' |
foo contains 'bar' (anywhere) |
foo:~%bar |
{foo: {$like: '%bar'}} |
WHERE foo LIKE '%bar' |
foo ends with 'bar' |
foo:~bar% |
{foo: {$like: 'bar%'}} |
WHERE foo LIKE 'bar%' |
foo starts with 'bar' |
IN clauses are indicated by a Value that is an array.
| GQL | JSON | SQL |
|---|---|---|
title:[introduction, overview] |
{title: ['introduction', 'overview']} |
WHERE title IN ('introduction', 'overview') |
Read about how to Negate a comparison.