Skip to main content
Version: edge


The record module contains functions to work with records.


combine(left, right)

Combines (aka merges) the two records left and right overwriting existing values in left with those provided in right

record::combine({"a": 1, "b": 2, "c": 4}, {"c": 3, "d": 4})
== {"a": 1, "b": 2, "c": 3, "d": 4}

Returns a record

contains(record, key)

Returns if an record contains a given key.

Returns a bool

extract(record, array)

Extracts a given set of field from an record, removing all others.

record::extract({"a": 1, "b": 2, "c": 3}, ["a", "c"]) == {"a": 1, "c": 3}

Returns a record


Turns an array of key value pairs into an record.

Note: array's elements need to be arrays of two elements with the first element being a string.

record::from_array([["a", 1], ["b", 2]]) == {"a": 1, "b": 2}

Returns a record


Returns if an record is empty.

Returns a bool


Returns an array of record keys.

record::keys({"a": 1, "b": 2}) == ["a", "b"]

Returns a [string]


Returns the length of an record (number of key value pairs).

Returns an integer

rename(target, changes)

Renames the keys in the record target based on the key value pairs in the record changes where the key is the current name and the value is the new name.

record::rename({"a": 1, "b": 2, "c": 4}, {"a": "A", "b": "B"})
== {"A": 1, "B": 2, "c": 4}

Returns a record


Turns the record into an array of key value pairs.

record::to_array({"a": 1, "b": 2}) == [["a", 1], ["b", 2]]

Returns a [(string, any)]


Returns an array of record values.

record::values({"a": 1, "b": 2}) == [1, 2]

Returns a [any]