pulid

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 11 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 fluent 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) MarshalGQL

func (u ID) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*ID) Scan

func (u *ID) Scan(src interface{}) error

Scan implements the Scanner interface.

func (*ID) UnmarshalGQL

func (u *ID) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

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 fluent Mixin that captures the PULID prefix for a type.

func MixinWithPrefix

func MixinWithPrefix(prefix string) *Mixin

MixinWithPrefix 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() []fluent.Field

Fields provides the id field.

Jump to

Keyboard shortcuts

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