Object functions
These functions can be used when working with, and manipulating data objects.
| Function | Description |
|---|---|
object::entries() | Transforms an object into an array with arrays of key-value combinations. |
object::extend() | Extends an object with the content of another one. |
object::from_entries() | Transforms an array with arrays of key-value combinations into an object. |
object::is_empty() | Checks if an object is empty |
object::keys() | Returns an array with all the keys of an object. |
object::len() | Returns the amount of key-value pairs an object holds. |
object::remove() | Removes one or more fields from an object. |
object::values() | Returns an array with all the values of an object. |
object::entries
The object::entries function transforms an object into an array with arrays of key-value combinations.
The following example shows this function, and its output, when used in a RETURN statement:
object::extend
The object::extend function extends an object with the fields and values of another one, essentially adding the two together.
An example of the function, resulting in one new field (gold) and one updated field (last_updated) in the final output.
Note: the same behaviour can also be achieved using the + operator.
object::from_entries
The object::from_entries function transforms an array with arrays of key-value combinations into an object.
The following example shows this function, and its output, when used in a RETURN statement:
object::is_empty
The object::is_empty function checks whether the object contains values.
The following example shows this function, and its output, when used in a RETURN statement:
Example of .is_empty() being used in a DEFINE FIELD statement to disallow empty objects:
object::keys
The object::keys function returns an array with all the keys of an object.
The following example shows this function, and its output, when used in a RETURN statement:
object::len
The object::len function returns the amount of key-value pairs an object holds.
The following example shows this function, and its output, when used in a RETURN statement:
object::remove
The object::remove function removes one or more fields from an object.
A single string can be used to remove a single field from an object, while an array of strings can be used to remove one or more fields at a time.
object::values
The object::values function returns an array with all the values of an object.
The following example shows this function, and its output, when used in a RETURN statement:
Method chaining
Method chaining allows functions to be called using the . dot operator on a value of a certain type instead of the full path of the function followed by the value.
This is particularly useful for readability when a function is called multiple times.