Vercel Logo
DOCS
DEVELOPER GUIDELINE
QUERY AND SELECT

Query & Select

Querying and selecting data are fundamental operations in Syncraft, allowing you to fetch, filter, and format your data effectively. This guide will walk you through constructing a Query and Select pipeline using a practical example.

Let's break down the main components of a QueryAndSelect pipeline using the provided example:

Try In Playground
{ "query": { "id": { "eq": 2 } }, "selection": { "id": true, "name": true }, "root": "Users" }

Root (Model / Source Path)

The root specifies the starting point for retrieving data, such as a database table or a model name.

"root": "Users"

Query

The query block allows you to specify criteria and conditions to filter and retrieve specific data.

"query": { "id": { "eq": 2 } }

Selection

The selection block determines the output of the pipeline by specifying which fields to include.

"selection": { "id": true, "name": true }

Metadata

Query metadata are fields defining pagination and sorting.

"offset": 10, "limit": 20, "sortBy": "id", "direction": "DESC"

Pipeline Execution Flow

The execution of a pipeline is determined during the planner step, ensuring each piece has all necessary input available when called during the execution process.

Order of Operations

  1. Query for the "model field" and select the "model field".
  2. Execute transformations referring to the outer selection (Pipeline Input State) before running the relational pipeline.
  3. Execute the relational pipeline using an input state that matches the selection from the previous steps.
  4. Select all transformed fields that refer to the "own" state.

Constructing a QueryAndSelect pipeline in Syncraft requires a structured approach, understanding the flow of data, and how each section of the pipeline impacts the other. This guide should provide a clear pathway to building your own QueryAndSelect pipelines, enabling you to fetch, filter, and format your data effectively within Syncraft.

Learn More
Defining Models
Continue Your Journey
Cross-Sync Join