pulid

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package pulid implements the pulid type. A pulid is an identifier that is a two-byte prefixed ULIDs, with the first two bytes encoding the type of the entity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	Prefix string
}

Annotation captures the id prefix for a type.

func (Annotation) Name

func (a Annotation) Name() string

Name implements the ent Annotation interface.

type ID

type ID string

ID implements a PULID - a prefixed ULID.

func MustNew

func MustNew(prefix string) ID

MustNew returns a new PULID for time.Now() given a prefix. This uses the default entropy source.

func (*ID) Scan

func (u *ID) Scan(src any) error

Scan implements the Scanner interface.

func (ID) String

func (u ID) String() string

String implements the fmt.Stringer interface.

func (ID) TypeID

func (u ID) TypeID() (typeid.AnyID, error)

TypeID returns the type id of the PULID.

func (ID) Value

func (u ID) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Mixin

type Mixin struct {
	mixin.Schema
	// contains filtered or unexported fields
}

Mixin defines an ent Mixin that captures the PULID prefix for a type.

func NewMixinWithPrefix

func NewMixinWithPrefix(columnName, prefix string) *Mixin

NewMixinWithPrefix creates a Mixin that encodes the provided prefix.

func (Mixin) Annotations

func (m Mixin) Annotations() []schema.Annotation

Annotations returns the annotations for a Mixin instance.

func (Mixin) Fields

func (m Mixin) Fields() []ent.Field

Fields provides the id field.

Jump to

Keyboard shortcuts

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