Select specific properties with ::{} Â
Access properties of an item by using the property names as defined in the schema.
::{<property1>, <property2>, ...}
::{<property1>: <alias>, <property2>}
Property access allows you to return only the fields you need, reducing data transfer and improving query performance.
When using the SDKs or curling the endpoint, the query name must match what is defined in the
queries.hx file exactly.Example 1: Basic property selection
QUERY GetUserBasicInfo () =>
users <- N<User>::RANGE(0, 10)
RETURN users::{name, age}
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)
users = [
{"name": "Alice", "age": 25, "email": "alice@example.com"},
{"name": "Bob", "age": 30, "email": "bob@example.com"},
{"name": "Charlie", "age": 28, "email": "charlie@example.com"},
{"name": "Diana", "age": 22, "email": "diana@example.com"},
]
for user in users:
client.query("CreateUser", user)
result = client.query("GetUserBasicInfo", {})
print("User basic info:", 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 users = vec![
("Alice", 25, "alice@example.com"),
("Bob", 30, "bob@example.com"),
("Charlie", 28, "charlie@example.com"),
("Diana", 22, "diana@example.com"),
];
for (name, age, email) in &users {
let _created: serde_json::Value = client.query("CreateUser", &json!({
"name": name,
"age": age,
"email": email,
})).await?;
}
let result: serde_json::Value = client.query("GetUserBasicInfo", &json!({})).await?;
println!("User basic info: {result:#?}");
Ok(())
}
package main
import (
"fmt"
"log"
"github.com/HelixDB/helix-go"
)
func main() {
client := helix.NewClient("http://localhost:6969")
users := []map[string]any{
{"name": "Alice", "age": uint8(25), "email": "alice@example.com"},
{"name": "Bob", "age": uint8(30), "email": "bob@example.com"},
{"name": "Charlie", "age": uint8(28), "email": "charlie@example.com"},
{"name": "Diana", "age": uint8(22), "email": "diana@example.com"},
}
for _, user := range users {
var created map[string]any
if err := client.Query("CreateUser", helix.WithData(user)).Scan(&created); err != nil {
log.Fatalf("CreateUser failed: %s", err)
}
}
var result map[string]any
if err := client.Query("GetUserBasicInfo", helix.WithData(map[string]any{})).Scan(&result); err != nil {
log.Fatalf("GetUserBasicInfo failed: %s", err)
}
fmt.Printf("User basic info: %#v\n", result)
}
import HelixDB from "helix-ts";
async function main() {
const client = new HelixDB("http://localhost:6969");
const users = [
{ name: "Alice", age: 25, email: "alice@example.com" },
{ name: "Bob", age: 30, email: "bob@example.com" },
{ name: "Charlie", age: 28, email: "charlie@example.com" },
{ name: "Diana", age: 22, email: "diana@example.com" },
];
for (const user of users) {
await client.query("CreateUser", user);
}
const result = await client.query("GetUserBasicInfo", {});
console.log("User basic info:", result);
}
main().catch((err) => {
console.error("GetUserBasicInfo 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/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Bob","age":30,"email":"bob@example.com"}'
curl -X POST \
http://localhost:6969/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Charlie","age":28,"email":"charlie@example.com"}'
curl -X POST \
http://localhost:6969/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Diana","age":22,"email":"diana@example.com"}'
curl -X POST \
http://localhost:6969/GetUserBasicInfo \
-H 'Content-Type: application/json' \
-d '{}'
Example 2: Property selection with renaming
QUERY GetUserDisplayInfo () =>
users <- N<User>::RANGE(0, 10)
RETURN users::{displayName: name, userAge: age}
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)
users = [
{"name": "Alice", "age": 25, "email": "alice@example.com"},
{"name": "Bob", "age": 30, "email": "bob@example.com"},
{"name": "Charlie", "age": 28, "email": "charlie@example.com"},
{"name": "Diana", "age": 22, "email": "diana@example.com"},
]
for user in users:
client.query("CreateUser", user)
result = client.query("GetUserDisplayInfo", {})
print("User display info:", 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 users = vec![
("Alice", 25, "alice@example.com"),
("Bob", 30, "bob@example.com"),
("Charlie", 28, "charlie@example.com"),
("Diana", 22, "diana@example.com"),
];
for (name, age, email) in &users {
let _created: serde_json::Value = client.query("CreateUser", &json!({
"name": name,
"age": age,
"email": email,
})).await?;
}
let result: serde_json::Value = client.query("GetUserDisplayInfo", &json!({})).await?;
println!("User display info: {result:#?}");
Ok(())
}
package main
import (
"fmt"
"log"
"github.com/HelixDB/helix-go"
)
func main() {
client := helix.NewClient("http://localhost:6969")
users := []map[string]any{
{"name": "Alice", "age": uint8(25), "email": "alice@example.com"},
{"name": "Bob", "age": uint8(30), "email": "bob@example.com"},
{"name": "Charlie", "age": uint8(28), "email": "charlie@example.com"},
{"name": "Diana", "age": uint8(22), "email": "diana@example.com"},
}
for _, user := range users {
var created map[string]any
if err := client.Query("CreateUser", helix.WithData(user)).Scan(&created); err != nil {
log.Fatalf("CreateUser failed: %s", err)
}
}
var result map[string]any
if err := client.Query("GetUserDisplayInfo", helix.WithData(map[string]any{})).Scan(&result); err != nil {
log.Fatalf("GetUserDisplayInfo failed: %s", err)
}
fmt.Printf("User display info: %#v\n", result)
}
import HelixDB from "helix-ts";
async function main() {
const client = new HelixDB("http://localhost:6969");
const users = [
{ name: "Alice", age: 25, email: "alice@example.com" },
{ name: "Bob", age: 30, email: "bob@example.com" },
{ name: "Charlie", age: 28, email: "charlie@example.com" },
{ name: "Diana", age: 22, email: "diana@example.com" },
];
for (const user of users) {
await client.query("CreateUser", user);
}
const result = await client.query("GetUserDisplayInfo", {});
console.log("User display info:", result);
}
main().catch((err) => {
console.error("GetUserDisplayInfo 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/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Bob","age":30,"email":"bob@example.com"}'
curl -X POST \
http://localhost:6969/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Charlie","age":28,"email":"charlie@example.com"}'
curl -X POST \
http://localhost:6969/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Diana","age":22,"email":"diana@example.com"}'
curl -X POST \
http://localhost:6969/GetUserDisplayInfo \
-H 'Content-Type: application/json' \
-d '{}'
Access unique identifiers with ::ID Â
Access the unique identifier of any node, edge, or vector.
::ID
Every element in HelixDB has a unique ID that can be accessed using the
::ID syntax.When using the SDKs or curling the endpoint, the query name must match what is defined in the
queries.hx file exactly.Example 1: Getting element IDs
QUERY GetUserIDs () =>
users <- N<User>::RANGE(0, 5)
RETURN users::ID
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)
users = [
{"name": "Alice", "age": 25, "email": "alice@example.com"},
{"name": "Bob", "age": 30, "email": "bob@example.com"},
{"name": "Charlie", "age": 28, "email": "charlie@example.com"},
]
for user in users:
client.query("CreateUser", user)
result = client.query("GetUserIDs", {})
print("User IDs:", 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 users = vec![
("Alice", 25, "alice@example.com"),
("Bob", 30, "bob@example.com"),
("Charlie", 28, "charlie@example.com"),
];
for (name, age, email) in &users {
let _created: serde_json::Value = client.query("CreateUser", &json!({
"name": name,
"age": age,
"email": email,
})).await?;
}
let result: serde_json::Value = client.query("GetUserIDs", &json!({})).await?;
println!("User IDs: {result:#?}");
Ok(())
}
package main
import (
"fmt"
"log"
"github.com/HelixDB/helix-go"
)
func main() {
client := helix.NewClient("http://localhost:6969")
users := []map[string]any{
{"name": "Alice", "age": uint8(25), "email": "alice@example.com"},
{"name": "Bob", "age": uint8(30), "email": "bob@example.com"},
{"name": "Charlie", "age": uint8(28), "email": "charlie@example.com"},
}
for _, user := range users {
var created map[string]any
if err := client.Query("CreateUser", helix.WithData(user)).Scan(&created); err != nil {
log.Fatalf("CreateUser failed: %s", err)
}
}
var result map[string]any
if err := client.Query("GetUserIDs", helix.WithData(map[string]any{})).Scan(&result); err != nil {
log.Fatalf("GetUserIDs failed: %s", err)
}
fmt.Printf("User IDs: %#v\n", result)
}
import HelixDB from "helix-ts";
async function main() {
const client = new HelixDB("http://localhost:6969");
const users = [
{ name: "Alice", age: 25, email: "alice@example.com" },
{ name: "Bob", age: 30, email: "bob@example.com" },
{ name: "Charlie", age: 28, email: "charlie@example.com" },
];
for (const user of users) {
await client.query("CreateUser", user);
}
const result = await client.query("GetUserIDs", {});
console.log("User IDs:", result);
}
main().catch((err) => {
console.error("GetUserIDs 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/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Bob","age":30,"email":"bob@example.com"}'
curl -X POST \
http://localhost:6969/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Charlie","age":28,"email":"charlie@example.com"}'
curl -X POST \
http://localhost:6969/GetUserIDs \
-H 'Content-Type: application/json' \
-d '{}'
Include all properties with .. Â
Use the spread operator to include all properties while optionally remapping specific fields.
::{
<alias>: <property>,
..
}
When using the SDKs or curling the endpoint, the query name must match what is defined in the
queries.hx file exactly.Example 1: Property aliasing with spread operator
QUERY GetUsersWithAlias () =>
users <- N<User>::RANGE(0, 5)
RETURN users::{
userID: ID,
..
}
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)
users = [
{"name": "Alice", "age": 25, "email": "alice@example.com"},
{"name": "Bob", "age": 30, "email": "bob@example.com"},
{"name": "Charlie", "age": 28, "email": "charlie@example.com"},
]
for user in users:
client.query("CreateUser", user)
result = client.query("GetUsersWithAlias", {})
print("Users with alias:", 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 users = vec![
("Alice", 25, "alice@example.com"),
("Bob", 30, "bob@example.com"),
("Charlie", 28, "charlie@example.com"),
];
for (name, age, email) in &users {
let _created: serde_json::Value = client.query("CreateUser", &json!({
"name": name,
"age": age,
"email": email,
})).await?;
}
let result: serde_json::Value = client.query("GetUsersWithAlias", &json!({})).await?;
println!("Users with alias: {result:#?}");
Ok(())
}
package main
import (
"fmt"
"log"
"github.com/HelixDB/helix-go"
)
func main() {
client := helix.NewClient("http://localhost:6969")
users := []map[string]any{
{"name": "Alice", "age": uint8(25), "email": "alice@example.com"},
{"name": "Bob", "age": uint8(30), "email": "bob@example.com"},
{"name": "Charlie", "age": uint8(28), "email": "charlie@example.com"},
}
for _, user := range users {
var created map[string]any
if err := client.Query("CreateUser", helix.WithData(user)).Scan(&created); err != nil {
log.Fatalf("CreateUser failed: %s", err)
}
}
var result map[string]any
if err := client.Query("GetUsersWithAlias", helix.WithData(map[string]any{})).Scan(&result); err != nil {
log.Fatalf("GetUsersWithAlias failed: %s", err)
}
fmt.Printf("Users with alias: %#v\n", result)
}
import HelixDB from "helix-ts";
async function main() {
const client = new HelixDB("http://localhost:6969");
const users = [
{ name: "Alice", age: 25, email: "alice@example.com" },
{ name: "Bob", age: 30, email: "bob@example.com" },
{ name: "Charlie", age: 28, email: "charlie@example.com" },
];
for (const user of users) {
await client.query("CreateUser", user);
}
const result = await client.query("GetUsersWithAlias", {});
console.log("Users with alias:", result);
}
main().catch((err) => {
console.error("GetUsersWithAlias 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/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Bob","age":30,"email":"bob@example.com"}'
curl -X POST \
http://localhost:6969/CreateUser \
-H 'Content-Type: application/json' \
-d '{"name":"Charlie","age":28,"email":"charlie@example.com"}'
curl -X POST \
http://localhost:6969/GetUsersWithAlias \
-H 'Content-Type: application/json' \
-d '{}'