jsontypeent

package module
v0.0.0-...-c011194 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

README

jsontype-ent

Ent field helper for github.com/ubgo/jsontype. One line of schema instead of remembering the right field.JSON(name, jsontype.JSON{}) incantation.

Install

go get github.com/ubgo/jsontype-ent

Use

import (
    "entgo.io/ent"
    "entgo.io/ent/schema"

    jsontypeent "github.com/ubgo/jsontype-ent"
)

type Event struct{ ent.Schema }

func (Event) Fields() []ent.Field {
    return []ent.Field{
        jsontypeent.Field("payload"),
    }
}

For finer control (Optional, Immutable, dialect-specific column type, comments, etc.) compose directly:

field.JSON("payload", jsontype.JSON{}).
    Optional().
    Comment("free-form JSON event payload").
    SchemaType(map[string]string{"postgres": "jsonb"})

The helper is for the 90% case. The full ent API stays one import away.

License

Apache-2.0 — see LICENSE.

Documentation

Overview

Package jsontypeent provides an ent.Field constructor for github.com/ubgo/jsontype.JSON columns.

The helper is intentionally narrow: it returns a sensibly-defaulted field. For finer control (Optional, Immutable, Comment, StorageKey, SchemaType per dialect, etc.) compose directly:

field.JSON("metadata", jsontype.JSON{}).Optional().Comment("...")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Field

func Field(name string) ent.Field

Field returns an ent.Field for a jsontype.JSON column. The column is stored as JSON / JSONB at the SQL layer; ent picks the appropriate type for the dialect.

Types

This section is empty.

Jump to

Keyboard shortcuts

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