virtual-fields

command
v0.27.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 5 Imported by: 0

README

Virtual Fields Example

This example shows how to expose virtual attributes as top-level API fields while persisting them into a JSON/JSONB map.

  • Virtual fields are declared with crud:"virtual:<mapField>" and bun:"-".
  • The handler moves values into/out of the map automatically via lifecycle hooks.
  • PreserveVirtualKeys defaults to true so responses keep both virtuals and raw metadata; set to false if you want the map to drop known virtual keys.
  • Pointers (*string, *bool) let you distinguish “absent” from “explicit zero”; allow_zero tag opt-in exists for value fields.
  • Merge semantics: PUT = replace, PATCH = merge (JSON Merge Patch) with delete-on-null; per-field merge:deep|shallow tag can override.

See main.go for a minimal setup with hooks and controller registration.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址