mongoid

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewULID

func NewULID() string

NewULID generates a new ULID string

Types

type Collection

type Collection interface {
	FindOne(ctx context.Context, filter any) FindOneResult
	UpdateOne(ctx context.Context, filter, update any) (UpdateResult, error)
	DeleteOne(ctx context.Context, filter any) (DeleteResult, error)
}

Collection interface represents the minimal collection interface needed for ULID operations This allows the package to work with different collection implementations

type DeleteResult

type DeleteResult struct {
	DeletedCount int64
}

DeleteResult represents the result of a delete operation

func DeleteByObjectID

func DeleteByObjectID(ctx context.Context, coll Collection, id any) (DeleteResult, error)

DeleteByObjectID deletes a document by its ObjectID

func DeleteByULID

func DeleteByULID(ctx context.Context, coll Collection, id string) (DeleteResult, error)

DeleteByULID deletes a document by its ULID

type FindOneResult

type FindOneResult interface {
	Decode(v any) error
}

FindOneResult interface represents the result of a FindOne operation

func FindByObjectID

func FindByObjectID(ctx context.Context, coll Collection, id any) FindOneResult

FindByObjectID finds a document by its ObjectID

func FindByULID

func FindByULID(ctx context.Context, coll Collection, id string) FindOneResult

FindByULID finds a document by its ULID

type ULID

type ULID struct {
	// contains filtered or unexported fields
}

ULID represents a ULID identifier with helper methods

func ParseULID

func ParseULID(str string) (ULID, error)

ParseULID parses a ULID string and returns a ULID struct

func (ULID) IsZero

func (u ULID) IsZero() bool

IsZero returns true if the ULID is zero/empty

func (ULID) String

func (u ULID) String() string

String returns the string representation of the ULID

func (ULID) Time

func (u ULID) Time() time.Time

Time extracts the timestamp from the ULID

type UpdateResult

type UpdateResult struct {
	MatchedCount  int64
	ModifiedCount int64
	UpsertedCount int64
	UpsertedID    any
}

UpdateResult represents the result of an update operation

func UpdateByObjectID

func UpdateByObjectID(ctx context.Context, coll Collection, id any, updateDoc *update.Builder) (UpdateResult, error)

UpdateByObjectID updates a document by its ObjectID

func UpdateByULID

func UpdateByULID(ctx context.Context, coll Collection, id string, updateDoc *update.Builder) (UpdateResult, error)

UpdateByULID updates a document by its ULID

Jump to

Keyboard shortcuts

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