record
The record module contains functions to work with records.
Functions
extract(record, array)
Extract
s 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
combine(left, right)
Combine
s (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
from_array(array)
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
is_empty(record)
Returns if an record is empty.
Returns a bool
len(record)
Returns the length of an record (number of key value pairs).
Returns an integer
contains(record, key)
Returns if an record contains a given key.
Returns a bool
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
to_array(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)]
values(record)
Returns an array of record values.
record::values({"a": 1, "b": 2}) == [1, 2]
Returns a [any]
keys(record)
Returns an array of record keys.
record::keys({"a": 1, "b": 2}) == ["a", "b"]
Returns a [string]