Accessing Properties
You can access properties of an item by using the name of the property as defined
in the schema.
// Get specific properties
::{<SchemaFieldNames>}
In schema.hx:
N::User{
Name: String,
Email: String,
Age: U32,
Posts: U32
}
In query.hx:
QUERY findUsers() =>
users <- N<User>::RANGE(0, 10)
RETURN users::{ Name, Age }
Here we are accessing the Name
and Age
properties of each user.
JSON Output:
"users": [
{
"Name": "John",
"Age": 30
},
...
]
Accessing the ID
QUERY findUsers() =>
users <- N<User>::RANGE(0, 10)
RETURN users::ID
"users": [
{
"id": "c2ca233f-0cd8-4fae-8136-b40593792071"
},
...
]
Spread Operator
Using the spread operator, you can remap values while including all
other properties of the selected element in the returned object.
In schema.hx:
N::User{
name: String,
age: U32,
}
In query.hx:
QUERY findUsers() =>
users <- N<User>::RANGE(0, 10)
RETURN users::{
userID: ID,
..
}
JSON Output:
"users": [
{
"userID": "c2ca233f-0cd8-4fae-8136-b40593792071",
"name": "John",
"age": 30
},
...
]