Struct Functions

Struct Functions

field

available since: 1.0.0

Takes a struct value and a field name. Returns the field's value.

struct {}T

Example:

Query:
e.field("a", e.data(d.struct({
  • a: d.int8(1),
  • b: d.int8(2),
  • c: d.int8(3),
}
)
)
)
Result:
1

setField

available since: 1.0.0

Takes a struct value and sets the given field name to the specified value. Returns the resulting struct value.

struct {}struct {
  • name :V
}

Example:

Query:
e.setField({
  • name: "d",
  • value: d.int8(4),
  • in: e.data(d.struct({
    • a: d.int8(1),
    • b: d.int8(2),
    • c: d.int8(3),
    }
    )
    )
    ,
}
)
Result:
{ "a": 1, "b": 2, "c": 3, "d": 4 }

extractStrings

available since: 1.0.0

extractStrings takes a single argument, which may be an arbitrarily complex object. It returns all string values contained in the argument as a list. The list has unspecified order, however it may be sorted lexicographically.

Example:

Query:
e.extractStrings(e.data(d.struct({
  • a: d.int8(1),
  • b: d.string("foo"),
  • c: d.struct({
    • list: d.list(d.string("bar"), d.string("baz")),
    }
    )
    ,
}
)
)
)
Result:
[ "bar", "baz", "foo" ]