Vercel Logo
DOCS
GETTING STARTED
FIRST QUERY

Write Your First Query

Welcome to your first hands-on experience with Syncraft! This tutorial will guide you through the basics of writing and executing a query on our platform. In Syncraft, every query is structured with three fundamental elements: Root, Selection, and Query.

Let’s break down these elements:

  • Root: This specifies the data access path, like a database table or an API endpoint.
  • Selection: Determines which fields to include in the output of the pipeline.
  • Query: This is where you specify the criteria to filter and retrieve specific data.

Now, let's construct a simple query to retrieve user data:

Example Query: Fetching User Data

Suppose we have a database of users and we want to fetch the details of the user with id equal to 2.

Step 1: Define the Root

"root": "Users"

Step 2: Specify the Selection

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

Step 3: Construct the Query

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

Full Query

Combining all the elements, our query looks like this:

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

Now, execute this query on the Syncraft platform. You'll receive a response with the details of the user with id equal to 2.

Congratulations on writing and executing your first query! As you explore Syncraft further, you'll discover how to craft more complex queries to meet your data retrieval and processing needs. Happy querying!

Learn More
Learn How To Build Complex Queries
Continue Your Journey
Next Steps