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
| Argument | Type | Description |
|---|---|---|
name | string | The name value. |
resolver | Resolver[T] | The resolver value. |
Returns
The declared result.
VirtualField[T]Full signature
func Virtual[T VirtualValue](
name string,
resolver Resolver[T],
) VirtualField[T]Related types
VirtualValueVirtualValue 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.
ResolverResolver 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.
VirtualFieldVirtualField configures a computed response value that cannot be set by a write request. T is the value its resolver and response transforms use.