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::from_entries() | Transforms an array with arrays of key-value combinations into an object. |
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::values() | Returns an array with all the values of an object. |
object::entries
Available since: v1.1.0
The object::entries
function transforms an object into an array with arrays of key-value combinations.
API DEFINITIONobject::entries(object) -> array
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN object::entries({ a: 1, b: true }); [ [ "a", 1 ], [ "b", true ], ]
object::from_entries
Available since: v1.1.0
The object::from_entries
function transforms an array with arrays of key-value combinations into an object.
API DEFINITIONobject::from_entries(array) -> object
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN object::from_entries([ [ "a", 1 ], [ "b", true ], ]); { a: 1, b: true }
object::keys
Available since: v1.1.0
The object::keys
function returns an array with all the keys of an object.
API DEFINITIONobject::keys(object) -> array
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN object::keys({ a: 1, b: true }); [ "a", "b" ]
object::len
Available since: v1.1.0
The object::len
function returns the amount of key-value pairs an object holds.
API DEFINITIONobject::len(object) -> number
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN object::len({ a: 1, b: true }); 2
object::values
Available since: v1.1.0
The object::values
function returns an array with all the values of an object.
API DEFINITIONobject::values(object) -> array
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN object::values({ a: 1, b: true }); [ 1, true ]
Available since: v2.0.0
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.
-- Traditional syntax object::values({ a: 1, b: true }); -- Method chaining syntax { a: 1, b: true }.values();
Response[ 1, true ]
This is particularly useful for readability when a function is called multiple times.
-- Traditional syntax array::max(object::values(object::from_entries([["a", 1], ["b", 2]]))); -- Method chaining syntax object::from_entries([["a", 1], ["b", 2]]).values().max();
Response2