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:
{
"query": {
"id": {
"eq": 2
}
},
"selection": {
"id": true,
"name": true
},
"root": "Users"
}
The root specifies the starting point for retrieving data, such as a database table or a model name.
"root": "Users"
The query block allows you to specify criteria and conditions to filter and retrieve specific data.
"query": {
"id": {
"eq": 2
}
}
The selection block determines the output of the pipeline by specifying which fields to include.
"selection": {
"id": true,
"name": true
}
Query metadata are fields defining pagination and sorting.
"offset": 10,
"limit": 20,
"sortBy": "id",
"direction": "DESC"
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.
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.