function

Virtual

Virtual adds a computed field at the document root. The resolver's type sets the field's value type: string, float64, bool, or store.Value for any JSON value. Return operation.Present(value), or operation.Empty[T]() for null.

Arguments

ArgumentTypeDescription
namestringThe name value.
resolverResolver[T]The resolver value.

Returns

The declared result.

VirtualField[T]

Full signature

Related types

  • VirtualValue

    VirtualValue is a type a virtual field can compute: text as a string, a number as a float64, a checkbox value as a bool, or any JSON value as a store.Value.

  • Resolver

    Resolver calculates a root Virtual field for the response. Read other values from its context and return Present(value), Empty[T](), or an error. The value must match the declared Virtual type and remains subject to field read access.

  • VirtualField

    VirtualField configures a computed response value that cannot be set by a write request. T is the value its resolver and response transforms use.

Related guides