This video is available to students only

Formatting the query

Preparing for the server setup by processing the output of the query builder into database-ready SQL

The formatQuery function#

In this lesson we'll focus on the formatQuery function exported by react-querybuilder. formatQuery is useful for displaying different representations of the query, namely the internal JSON format ("json"), the internal format with rule identifiers stripped out ("json_without_ids"), SQL format ("sql"; the WHERE clause only), and a parameterized format useful for interacting with APIs.

Besides the format of the query representation, formatQuery has a couple of other options that can be set. valueProcessor is a function that will process rule values, and quoteFieldNamesWith will quote field names with the provided quote character in SQL mode.

The valueProcessor function#

No discussions yet