Create queries

Overview

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 skip(), take(), count(), order(), select(), and where()

NOTE: All queries that use the where() clause are implicitly followed by an and() operand. 
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.

Example

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:

Procedure

  1. Get the query object
    You start by calling the Query() function of the Sitefinity object.
    This function returns a Query object that is the entry point for building queries.
  2. 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. 

    The .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 done().

  3. Build the query
    After you build the query, you must build it by calling the the build() function on the query object.
  4. Use the query
    After you build the query, you can add it to a GET request to filter the items.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?