Queries, also known as filters, are strings that are appended in the request as query parameters. Sitefinity JS SDK allows you to build queries programmatically.
Queries can be built with functions such as
NOTE: All queries that use the
where() clause are implicitly followed by an
For example the query
query.where().and().endswith("Title", "Record").done().done() produces the string
(endswith(Title, 'Record')), which has a set of unused parenthesis - the outermost ones.
This article uses as example a query that returns items whose title ends with Record AND the age of the item is not equal to 15 OR the content equals test.
You build and use this query in the following way:
- Get the query object
You start by calling the
Query() function of the
This function returns a
Query object that is the entry point for building queries.
- Create the query
The query ANDs the result of the
endwith operator and the result of the
or operand, which holds inside the
ne (not equal) and
eq (equals) operators.
.done() functions are used to specify where the operation ends. It is required so that the filter can be closed. Each time you use an
and() or an
or() operand you must add a
- Build the query
After you build the query, you must build it by calling the the
build() function on the query object.
- Use the query
After you build the query, you can add it to a
GET request to filter the items.