Skip to main content
Version: 2.0.0

Constant Fields

A constant field is a purely output field whose value is set once at creation and never changes. Input values and updates are ignored.

Loading playground…

Default values

The constant value can be static or a resolver function. Resolvers receive the creation context and are evaluated once, when the entity is created.

Loading playground…

If a resolver throws, the field value becomes null.

Hooks

Constant fields support onDelete and onSuccess listeners.

b.constant("id", () => "user-123")
.onDelete((entity) => console.log("deleted", entity.id))
.onSuccess((summary) => console.log("created", summary.values.id));

API summary

MethodDescription
constant(name, value)Create a constant field with a static value or resolver.
onDelete(handler)Listener invoked by model.delete.
onSuccess(handler)Listener invoked after a successful create/update.