docs: add examples for regex operators (closes #6919)

GITHUB_PR_NUMBER: 7691
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/7691

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2618
Co-authored-by: Rafael Baldasso Audibert <32079912+rafaeelaudibert@users.noreply.github.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: eeec4eba087c10d7008092a1f70acc82e73c4fcc
This commit is contained in:
hasura-bot 2021-10-25 12:34:08 +02:00
parent 9f35e660c0
commit ec4ef91273

View File

@ -472,8 +472,8 @@ Fetch a list of those authors whose names are NOT part of a list:
} }
} }
Text search or pattern matching operators (_like, _similar, etc.) Text search or pattern matching operators (_like, _similar, _regex, etc.)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``_like``, ``_nlike``, ``_ilike``, ``_nilike``, ``_similar``, ``_nsimilar``, ``_regex``, ``_nregex``, ``_iregex``, ``_niregex`` operators are used for The ``_like``, ``_nlike``, ``_ilike``, ``_nilike``, ``_similar``, ``_nsimilar``, ``_regex``, ``_nregex``, ``_iregex``, ``_niregex`` operators are used for
pattern matching on string/text fields. pattern matching on string/text fields.
@ -512,6 +512,8 @@ Fetch a list of articles whose titles contain the word “amet”:
"title": "sit amet" "title": "sit amet"
} }
] ]
}
}
.. note:: .. note::
@ -561,6 +563,49 @@ Fetch a list of authors whose names begin with A or C:
``_similar`` is case-sensitive ``_similar`` is case-sensitive
**Example: _regex**
Fetch a list of articles whose titles match the regex “[ae]met”:
.. graphiql::
:view_only:
:query:
query {
articles(
where: {title: {_regex: "[ae]met"}}
) {
id
title
}
}
:response:
{
"data": {
"articles": [
{
"id": 1,
"title": "sit amet"
},
{
"id": 3,
"title": "cremet justo morbi"
},
{
"id": 9,
"title": "sit ametist"
}
]
}
}
.. note::
``_regex`` is case-sensitive. Use ``_iregex`` for case-insensitive search.
.. note::
``regex`` operators are supported in in ``v2.0.0`` and above
JSONB operators (_contains, _has_key, etc.) JSONB operators (_contains, _has_key, etc.)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^