Skip to main content
We’re going to create a simple social network where users can follow each other and create posts.

Prerequisites

Install the HelixDB CLI
Install the Helix container
Initialize a new project
Install the SDK of your choice (optional)
Setup the SDK of your choice (optional)

Step 1: Define the schema in schema.hx

We’re going to define the schema for our social network in schema.hx. We’re going to have User nodes where users can Follow other users. We’re also going to have Post nodes where users can Create posts.
schema.hx

Step 2: Inserting data

Creating a user is done by inserting a new node into the graph.
To let users follow another user, we need to create an edge between them.
To create a post, we need to create a post node and an edge between the user and the post.

Step 3: Query the data

To get all users, we can use the following query:
To get all posts, we can use the following query:
To get all posts by a user, we can use the following query:
To get all users that a user follows, we can use the following query:
As a more complex example, we could have a query that loads an page containing the posts of users that a user follows. To do this we are going to remap the posts to have a field containing information about the user that created the post.

Step 4: Run the queries

To run the queries, we can use the following command