N Â Nodes
Select nodes from your graph to begin traversal.
N<Type>(node_id)
Example 1: Selecting a user by ID
QUERY GetUser (user_id: ID) =>
user <- N<User>(user_id)
RETURN user
QUERY CreateUser (name: String, age: U8, email: String) =>
user <- AddN<User>({
name: name,
age: age,
email: email
})
RETURN user
N::User {
name: String,
age: U8,
email: String,
}
from helix.client import Client
client = Client(local=True, port=6969)
user = client.query("CreateUser", {
"name": "Alice",
"age": 25,
"email": "alice@example.com",
})
user_id = user[0]["user"]["id"]
result = client.query("GetUser", {"user_id": user_id})
print(result)
use helix_rs::{HelixDB, HelixDBClient};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = HelixDB::new(Some("http://localhost"), Some(6969), None);
let alice: serde_json::Value = client.query("CreateUser", &json!({
"name": "Alice",
"age": 25,
"email": "alice@example.com",
})).await?;
let user_id = alice["user"]["id"].as_str().unwrap().to_string();
let result: serde_json::Value = client.query("GetUser", &json!({
"user_id": user_id,
})).await?;
println!("GetUser result: {result:#?}");
Ok(())
}
package main
import (
"fmt"
"log"
"github.com/HelixDB/helix-go"
)
func main() {
client := helix.NewClient("http://localhost:6969")
createPayload := map[string]any{
"name": "Alice",
"age": uint8(25),
"email": "alice@example.com",
}
var created map[string]any
if err := client.Query("CreateUser", helix.WithData(createPayload)).Scan(&created); err != nil {
log.Fatalf("CreateUser failed: %s", err)
}
userID := created["user"].(map[string]any)["id"].(string)
var result map[string]any
if err := client.Query("GetUser", helix.WithData(map[string]any{"user_id": userID})).Scan(&result); err != nil {
log.Fatalf("GetUser failed: %s", err)
}
fmt.Printf("GetUser result: %#v\n", result)
}
import HelixDB from "helix-ts";
async function main() {
const client = new HelixDB("http://localhost:6969");
const created = await client.query("CreateUser", {
name: "Alice",
age: 25,
email: "alice@example.com",
});
const userId: string = created.user.id;
const result = await client.query("GetUser", {
user_id: userId,
});
console.log("GetUser result:", result);
}
main().catch((err) => {
console.error("GetUser query failed:", err);
});
curl -X POST \
http://localhost:6969/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Alice","age":25,"email":"alice@example.com"}'
curl -X POST \
http://localhost:6969/GetUser \
-H 'Content-Type: application/json' \
-d '{"user_id":"<user_id>"}'
Example 2: Selecting all users
QUERY GetAllUsers () =>
users <- N<User>
RETURN users
N::User {
name: String,
age: U8,
email: String,
}
from helix.client import Client
client = Client(local=True, port=6969)
result = client.query("GetAllUsers")
print(result)
use helix_rs::{HelixDB, HelixDBClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = HelixDB::new(Some("http://localhost"), Some(6969), None);
let result: serde_json::Value = client.query("GetAllUsers", &()).await?;
println!("GetAllUsers result: {result:#?}");
Ok(())
}
package main
import (
"fmt"
"log"
"github.com/HelixDB/helix-go"
)
func main() {
client := helix.NewClient("http://localhost:6969")
var result map[string]any
if err := client.Query("GetAllUsers").Scan(&result); err != nil {
log.Fatalf("GetAllUsers failed: %s", err)
}
fmt.Printf("GetAllUsers result: %#v\n", result)
}
import HelixDB from "helix-ts";
async function main() {
const client = new HelixDB("http://localhost:6969");
const result = await client.query("GetAllUsers", {});
console.log("GetAllUsers result:", result);
}
main().catch((err) => {
console.error("GetAllUsers query failed:", err);
});
curl -X POST \
http://localhost:6969/GetAllUsers \
-H 'Content-Type: application/json' \
-d '{}'
You can also do specific property-based filtering, e.g., returning only ID, see the Property Filtering. You can also do aggregation steps, e.g., returning the count of nodes, see the Aggregations.