repo

package
v0.0.0-...-a04dae3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateObjectID

func GenerateObjectID() (primitive.ObjectID, error)

func ObjectIDToUUIDBytes

func ObjectIDToUUIDBytes(oi primitive.ObjectID) (res [16]byte, err error)

Types

type Connection

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

func Connect

func Connect(uri string, db string) (*Connection, error)

type Repo

type Repo[T any, K any] struct {
	// contains filtered or unexported fields
}

func NewRepo

func NewRepo[T any, K any](connection *Connection, config RepoConfig[K]) *Repo[T, K]

func NewRepoWithObjectID

func NewRepoWithObjectID[T any, K any](connection *Connection, collection string) *Repo[T, K]

func (*Repo[T, K]) ApplyId

func (r *Repo[T, K]) ApplyId(data *T) (err error)

func (*Repo[T, K]) Delete

func (r *Repo[T, K]) Delete(data T) (count int64, err error)

func (*Repo[T, K]) DeleteById

func (r *Repo[T, K]) DeleteById(id K) (count int64, err error)

func (*Repo[T, K]) Find

func (r *Repo[T, K]) Find(filter map[string]interface{}) (result []T, err error)

func (*Repo[T, K]) Get

func (r *Repo[T, K]) Get(id K) (data T, err error)

func (*Repo[T, K]) IdToUUIDBytes

func (r *Repo[T, K]) IdToUUIDBytes(id K) (res [16]byte, err error)

func (*Repo[T, K]) Insert

func (r *Repo[T, K]) Insert(data T) (id K, err error)

func (*Repo[T, K]) New

func (r *Repo[T, K]) New(ids ...K) (data T, err error)

func (*Repo[T, K]) Save

func (r *Repo[T, K]) Save(data T) (uid K, err error)

func (*Repo[T, K]) SetTimeout

func (r *Repo[T, K]) SetTimeout(timeout int)

func (*Repo[T, K]) Update

func (r *Repo[T, K]) Update(id K, data T) (uid K, err error)

type RepoConfig

type RepoConfig[K any] struct {
	Collection    string
	GenerateID    RepoIdGeneratorFunc[K]
	IDToUUIDBytes RepoToUUIDBytesFunc[K]
}

type RepoIdGeneratorFunc

type RepoIdGeneratorFunc[K any] func() (K, error)

type RepoToUUIDBytesFunc

type RepoToUUIDBytesFunc[K any] func(K) ([16]byte, error)

Jump to

Keyboard shortcuts

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