1. Property Access

Accessing Properties

// Get specific properties
::{Name, Age}

Appending the above to the end of a traversal will return an object with the specified properties like so:

[
    {
        Name: "John",
        Age: 30
    }, 
    ...
]

Accessing the ID

// Get the ID of the selected element using the standard access
::{id}

// Or use the ID function
::ID

Spread Operator

Using the spread operator, you can include all properties of the selected element in the returned object.

::{
    userID: id,
    .. // this is the spread operator to include everything else as is
}

2. Property Addition

// Add/update properties
::{
    userID: id, // accesses the id of each user
    followerCount: _::In<Follows>::COUNT // counts  the number of users that follow each user
}

By defining new properties, you can modify the object returned by the traversal. The above will return an object like so:

[
    {
        userID: <id>,
        followerCount: <Some Number>
    }, 
    ...
]

3. Property Exclusion

If you want to access all properties except for a few, you can use the exclude operator.

// Get all properties except for the id and the name
::!{
    id, name
}

4. Nested Mappings

If you want to access a propertis that traverse from the selected element, you can use the nested variable to continue the traversal.

// Defines **usr** as a variable that can me used inside the mapping
::|item|{
            following: item::In<Follows>,
            posts: posts::{
                postID: ID,
                creatorID: item::ID,
                .. // this is the spread operator to include everything else as is
            },
        }

5. Returning a Range

To return an certain amount of elements, you can use the RANGE function.

// Get the first 10 users
users <- N<User>::RANGE(0, 10)

// Get 10 users starting from the 10th user
users <- N<User>::RANGE(10, 20)