mixin

package
v0.0.0-...-cb5b6c1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mixin defines reusable groups of schema declarations, including application-side and database-side primary-key generators.

Index

Constants

View Source
const DefaultNanoIDAlphabet = "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

DefaultNanoIDAlphabet is the URL-safe alphabet used by NanoID's default configuration.

Variables

View Source
var SoftDelete = schema.Mixin{Fields: schema.Fields{
	field.Time("deleted_at").Optional().Annotate(softDeleteAnnotation{}),
}}

SoftDelete supplies a nullable deleted_at field and reserved annotation.

View Source
var Timestamps = schema.Mixin{Fields: schema.Fields{
	field.Time("created_at").SQLDefault("now()").Immutable(),
	field.Time("updated_at").SQLDefault("now()"),
}}

Timestamps supplies created_at and updated_at fields.

View Source
var ULID = schema.Mixin{Fields: schema.Fields{
	field.ID().Default(schema.Func(newULID)),
}}

ULID supplies a text primary key with a per-row ULID default.

UUIDv7 supplies a UUID primary key with a per-row UUIDv7 default.

Functions

func NanoID

func NanoID(size int, alphabet string) schema.Mixin

NanoID supplies a text primary key whose value is generated by PostgreSQL. The function defaults are declared as part of the desired migration object, so callers may also invoke nanoid(size, alphabet, additionalBytesFactor) directly when they need a non-default value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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