repository

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Code generated by volcago. DO NOT EDIT. generated version: (devel)

Code generated by volcago. DO NOT EDIT. generated version: (devel)

Code generated by volcago. DO NOT EDIT. generated version: (devel)

Code generated by volcago. DO NOT EDIT. generated version: (devel)

Code generated by volcago. DO NOT EDIT. generated version: (devel)

Code generated by volcago. DO NOT EDIT. generated version: (devel)

Code generated by volcago. DO NOT EDIT. generated version: (devel)

Code generated by volcago. DO NOT EDIT. generated version: (devel)

Index

Constants

View Source
const (
	LockIndexLabelTextEqual            = "t4" // perfect-match of Text
	LockIndexLabelTextLike             = "t3" // like-match of Text
	LockIndexLabelTextPrefix           = "t1" // prefix-match of Text
	LockIndexLabelTextSuffix           = "t2" // suffix-match of Text
	LockIndexLabelEmailEqual           = "e4" // perfect-match of Email
	LockIndexLabelEmailLike            = "e3" // like-match of Email
	LockIndexLabelEmailPrefix          = "e1" // prefix-match of Email
	LockIndexLabelEmailSuffix          = "e2" // suffix-match of Email
	LockIndexLabelFlagPrefix           = "f1" // prefix-match of Flag
	LockIndexLabelFlagSuffix           = "f2" // suffix-match of Flag
	LockIndexLabelFlagLike             = "f3" // like-match of Flag
	LockIndexLabelFlagEqual            = "f4" // perfect-match of Flag
	LockIndexLabelInterfacePrefix      = "i1" // prefix-match of Interface
	LockIndexLabelInterfaceSuffix      = "i2" // suffix-match of Interface
	LockIndexLabelInterfaceLike        = "i3" // like-match of Interface
	LockIndexLabelInterfaceEqual       = "i4" // perfect-match of Interface
	LockIndexLabelMapInterfacePrefix   = "m1" // prefix-match of MapInterface
	LockIndexLabelMapInterfaceSuffix   = "m2" // suffix-match of MapInterface
	LockIndexLabelMapInterfaceLike     = "m3" // like-match of MapInterface
	LockIndexLabelMapInterfaceEqual    = "m4" // perfect-match of MapInterface
	LockIndexLabelNested_NameEqual     = "n4" // perfect-match of Nested.Name
	LockIndexLabelNested_NameLike      = "n3" // like-match of Nested.Name
	LockIndexLabelNested_NamePrefix    = "n1" // prefix-match of Nested.Name
	LockIndexLabelNested_NameSuffix    = "n2" // suffix-match of Nested.Name
	LockIndexLabelNestedPtr_NameEqual  = "n8" // perfect-match of NestedPtr.Name
	LockIndexLabelNestedPtr_NameLike   = "n7" // like-match of NestedPtr.Name
	LockIndexLabelNestedPtr_NamePrefix = "n5" // prefix-match of NestedPtr.Name
	LockIndexLabelNestedPtr_NameSuffix = "n6" // suffix-match of NestedPtr.Name
	LockIndexLabelSliceStringPrefix    = "s1" // prefix-match of SliceString
	LockIndexLabelSliceStringSuffix    = "s2" // suffix-match of SliceString
	LockIndexLabelSliceStringLike      = "s3" // like-match of SliceString
	LockIndexLabelSliceStringEqual     = "s4" // perfect-match of SliceString
	LockIndexLabelSliceNestedPrefix    = "s5" // prefix-match of SliceNested
	LockIndexLabelSliceNestedSuffix    = "s6" // suffix-match of SliceNested
	LockIndexLabelSliceNestedLike      = "s7" // like-match of SliceNested
	LockIndexLabelSliceNestedEqual     = "s8" // perfect-match of SliceNested
	LockIndexLabelCreatedAtPrefix      = "c1" // prefix-match of CreatedAt
	LockIndexLabelCreatedAtSuffix      = "c2" // suffix-match of CreatedAt
	LockIndexLabelCreatedAtLike        = "c3" // like-match of CreatedAt
	LockIndexLabelCreatedAtEqual       = "c4" // perfect-match of CreatedAt
	LockIndexLabelCreatedByEqual       = "c8" // perfect-match of CreatedBy
	LockIndexLabelCreatedByLike        = "c7" // like-match of CreatedBy
	LockIndexLabelCreatedByPrefix      = "c5" // prefix-match of CreatedBy
	LockIndexLabelCreatedBySuffix      = "c6" // suffix-match of CreatedBy
	LockIndexLabelUpdatedAtPrefix      = "u1" // prefix-match of UpdatedAt
	LockIndexLabelUpdatedAtSuffix      = "u2" // suffix-match of UpdatedAt
	LockIndexLabelUpdatedAtLike        = "u3" // like-match of UpdatedAt
	LockIndexLabelUpdatedAtEqual       = "u4" // perfect-match of UpdatedAt
	LockIndexLabelUpdatedByEqual       = "u8" // perfect-match of UpdatedBy
	LockIndexLabelUpdatedByLike        = "u7" // like-match of UpdatedBy
	LockIndexLabelUpdatedByPrefix      = "u5" // prefix-match of UpdatedBy
	LockIndexLabelUpdatedBySuffix      = "u6" // suffix-match of UpdatedBy
	LockIndexLabelDeletedAtPrefix      = "d1" // prefix-match of DeletedAt
	LockIndexLabelDeletedAtSuffix      = "d2" // suffix-match of DeletedAt
	LockIndexLabelDeletedAtLike        = "d3" // like-match of DeletedAt
	LockIndexLabelDeletedAtEqual       = "d4" // perfect-match of DeletedAt
	LockIndexLabelDeletedByEqual       = "d8" // perfect-match of DeletedBy
	LockIndexLabelDeletedByLike        = "d7" // like-match of DeletedBy
	LockIndexLabelDeletedByPrefix      = "d5" // prefix-match of DeletedBy
	LockIndexLabelDeletedBySuffix      = "d6" // suffix-match of DeletedBy
	LockIndexLabelVersionPrefix        = "v1" // prefix-match of Version
	LockIndexLabelVersionSuffix        = "v2" // suffix-match of Version
	LockIndexLabelVersionLike          = "v3" // like-match of Version
	LockIndexLabelVersionEqual         = "v4" // perfect-match of Version
)

Variables

View Source
var (
	ErrAlreadyExists        = xerrors.New("already exists")
	ErrAlreadyDeleted       = xerrors.New("already been deleted")
	ErrNotFound             = xerrors.New("not found")
	ErrLogicallyDeletedData = xerrors.New("logically deleted data")
	ErrUniqueConstraint     = xerrors.New("unique constraint error")
	ErrNotAvailableCG       = xerrors.New("not available in collection groups")
	ErrVersionConflict      = xerrors.New("version conflict")
)

Functions

func IsSlice

func IsSlice(v interface{}) bool

IsSlice - slice judgment

func SetLastThreeToZero

func SetLastThreeToZero(t time.Time) time.Time

SetLastThreeToZero - set the last three digits to zero

Types

type Cursor

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

Cursor - query cursor

type DeleteMode

type DeleteMode int

DeleteMode - delete mode

const (
	DeleteModeSoft DeleteMode = iota + 1 // logical delete mode
	DeleteModeHard                       // physical delete mode
)

type DeleteOption

type DeleteOption struct {
	Mode DeleteMode
}

DeleteOption - option to delete logically or physically default: physical deletion use `DeleteModeSoft` or `DeleteModeHard

type Filter

type Filter struct {
	FilterTypes []FilterType
	Value       interface{}
}

Filter - filters of extra indexer

type FilterType

type FilterType = int

FilterType - extra indexes filters type

const (
	FilterTypeAdd FilterType = 1 << iota
	FilterTypeAddPrefix
	FilterTypeAddSuffix
	FilterTypeAddBiunigrams
	FilterTypeAddSomething
)

type GetOption

type GetOption struct {
	IncludeSoftDeleted bool
}

GetOption - option to include logical deletion data

type LockRepository

type LockRepository interface {
	// Single
	Get(ctx context.Context, id string, opts ...GetOption) (*model.Lock, error)
	GetWithDoc(ctx context.Context, doc *firestore.DocumentRef, opts ...GetOption) (*model.Lock, error)
	Insert(ctx context.Context, subject *model.Lock) (_ string, err error)
	Update(ctx context.Context, subject *model.Lock) (err error)
	StrictUpdate(ctx context.Context, id string, param *LockUpdateParam, opts ...firestore.Precondition) error
	Delete(ctx context.Context, subject *model.Lock, opts ...DeleteOption) (err error)
	DeleteByID(ctx context.Context, id string, opts ...DeleteOption) (err error)
	// Multiple
	GetMulti(ctx context.Context, ids []string, opts ...GetOption) ([]*model.Lock, error)
	InsertMulti(ctx context.Context, subjects []*model.Lock) (_ []string, er error)
	UpdateMulti(ctx context.Context, subjects []*model.Lock) (er error)
	DeleteMulti(ctx context.Context, subjects []*model.Lock, opts ...DeleteOption) (er error)
	DeleteMultiByIDs(ctx context.Context, ids []string, opts ...DeleteOption) (er error)
	// Single(Transaction)
	GetWithTx(tx *firestore.Transaction, id string, opts ...GetOption) (*model.Lock, error)
	GetWithDocWithTx(tx *firestore.Transaction, doc *firestore.DocumentRef, opts ...GetOption) (*model.Lock, error)
	InsertWithTx(ctx context.Context, tx *firestore.Transaction, subject *model.Lock) (_ string, err error)
	UpdateWithTx(ctx context.Context, tx *firestore.Transaction, subject *model.Lock) (err error)
	StrictUpdateWithTx(tx *firestore.Transaction, id string, param *LockUpdateParam, opts ...firestore.Precondition) error
	DeleteWithTx(ctx context.Context, tx *firestore.Transaction, subject *model.Lock, opts ...DeleteOption) (err error)
	DeleteByIDWithTx(ctx context.Context, tx *firestore.Transaction, id string, opts ...DeleteOption) (err error)
	// Multiple(Transaction)
	GetMultiWithTx(tx *firestore.Transaction, ids []string, opts ...GetOption) ([]*model.Lock, error)
	InsertMultiWithTx(ctx context.Context, tx *firestore.Transaction, subjects []*model.Lock) (_ []string, er error)
	UpdateMultiWithTx(ctx context.Context, tx *firestore.Transaction, subjects []*model.Lock) (er error)
	DeleteMultiWithTx(ctx context.Context, tx *firestore.Transaction, subjects []*model.Lock, opts ...DeleteOption) (er error)
	DeleteMultiByIDsWithTx(ctx context.Context, tx *firestore.Transaction, ids []string, opts ...DeleteOption) (er error)
	// Search
	Search(ctx context.Context, param *LockSearchParam, q *firestore.Query) ([]*model.Lock, error)
	SearchWithTx(tx *firestore.Transaction, param *LockSearchParam, q *firestore.Query) ([]*model.Lock, error)
	SearchByParam(ctx context.Context, param *LockSearchParam) ([]*model.Lock, *PagingResult, error)
	SearchByParamWithTx(tx *firestore.Transaction, param *LockSearchParam) ([]*model.Lock, *PagingResult, error)
	// misc
	GetCollection() *firestore.CollectionRef
	GetCollectionName() string
	GetDocRef(id string) *firestore.DocumentRef
	RunInTransaction() func(ctx context.Context, f func(context.Context, *firestore.Transaction) error, opts ...firestore.TransactionOption) (err error)
	// get by unique field
	GetByText(ctx context.Context, text string, opts ...GetOption) (*model.Lock, error)
	GetByTextWithTx(tx *firestore.Transaction, text string, opts ...GetOption) (*model.Lock, error)
	GetByEmail(ctx context.Context, email string, opts ...GetOption) (*model.Lock, error)
	GetByEmailWithTx(tx *firestore.Transaction, email string, opts ...GetOption) (*model.Lock, error)
}

LockRepository - Repository of Lock

func NewLockRepository

func NewLockRepository(firestoreClient *firestore.Client, middleware ...LockRepositoryMiddleware) LockRepository

NewLockRepository - constructor

type LockRepositoryMiddleware

type LockRepositoryMiddleware interface {
	BeforeInsert(ctx context.Context, subject *model.Lock) (bool, error)
	BeforeUpdate(ctx context.Context, old, subject *model.Lock) (bool, error)
	BeforeDelete(ctx context.Context, subject *model.Lock, opts ...DeleteOption) (bool, error)
	BeforeDeleteByID(ctx context.Context, ids []string, opts ...DeleteOption) (bool, error)
}

LockRepositoryMiddleware - middleware of LockRepository

type LockSearchParam

type LockSearchParam struct {
	ID           *QueryChainer
	Text         *QueryChainer
	Email        *QueryChainer
	Flag         *QueryChainer
	Interface    *QueryChainer
	MapInterface *QueryChainer
	Nested       struct {
		Name *QueryChainer
	}
	NestedPtr struct {
		Name *QueryChainer
	}
	SliceString *QueryChainer
	SliceNested *QueryChainer
	CreatedAt   *QueryChainer
	CreatedBy   *QueryChainer
	UpdatedAt   *QueryChainer
	UpdatedBy   *QueryChainer
	DeletedAt   *QueryChainer
	DeletedBy   *QueryChainer
	Version     *QueryChainer

	IncludeSoftDeleted bool
	CursorKey          string
	CursorLimit        int
}

LockSearchParam - params for search

type LockUpdateParam

type LockUpdateParam struct {
	Flag         interface{}
	Interface    interface{}
	MapInterface interface{}
	Nested       struct {
		Name interface{}
	}
	NestedPtr struct {
		Name interface{}
	}
	SliceString interface{}
	SliceNested interface{}
	CreatedAt   interface{}
	CreatedBy   interface{}
	UpdatedAt   interface{}
	UpdatedBy   interface{}
	DeletedAt   interface{}
	DeletedBy   interface{}
	Version     interface{}
}

LockUpdateParam - params for strict updates

type MultiError

type MultiError interface {
	GetIndex() int
	GetError() error
	Error() string
}

MultiError - multi error interface

func NewMultiError

func NewMultiError(index int, err error) MultiError

NewMultiError - constructor

type MultiErrors

type MultiErrors []MultiError

MultiErrors - multi errors

func NewMultiErrors

func NewMultiErrors() MultiErrors

NewMultiErrors - constructor

func (MultiErrors) Error

func (errs MultiErrors) Error() string

Error - multi errors string

type OpType

type OpType = string

OpType - operator type

const (
	OpTypeEqual              OpType = "=="
	OpTypeNotEqual           OpType = "!="
	OpTypeLessThan           OpType = "<"
	OpTypeLessThanOrEqual    OpType = "<="
	OpTypeGreaterThan        OpType = ">"
	OpTypeGreaterThanOrEqual OpType = ">="
	OpTypeIn                 OpType = "in"
	OpTypeNotIn              OpType = "not-in"
	OpTypeArrayContains      OpType = "array-contains"
	OpTypeArrayContainsAny   OpType = "array-contains-any"
)

type PagingResult added in v1.3.0

type PagingResult struct {
	NextCursorKey string
	Length        int
}

PagingResult - paging result

type Query

type Query struct {
	Operator OpType
	Value    interface{}
}

Query - query

func (*Query) IsSlice

func (q *Query) IsSlice() bool

IsSlice - slice judgment

type QueryBuilder

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

QueryBuilder - query builder

func NewQueryBuilder

func NewQueryBuilder(collection *firestore.CollectionRef) *QueryBuilder

NewQueryBuilder - constructor

func (*QueryBuilder) ArrayContains

func (qb *QueryBuilder) ArrayContains(path string, value interface{}) *QueryBuilder

ArrayContains - array filter ( `array-contains` )

func (*QueryBuilder) ArrayContainsAny

func (qb *QueryBuilder) ArrayContainsAny(path string, value interface{}) *QueryBuilder

ArrayContainsAny - array filter ( `array-contains-any` )

func (*QueryBuilder) Asc

func (qb *QueryBuilder) Asc(path string) *QueryBuilder

Asc - order

func (*QueryBuilder) Check

func (qb *QueryBuilder) Check() error

Check - condition check

func (*QueryBuilder) Desc

func (qb *QueryBuilder) Desc(path string) *QueryBuilder

Desc - order

func (*QueryBuilder) EndAt

func (qb *QueryBuilder) EndAt(docSnapshotOrFieldValues ...interface{}) *QueryBuilder

EndAt - end at

func (*QueryBuilder) EndBefore

func (qb *QueryBuilder) EndBefore(docSnapshotOrFieldValues ...interface{}) *QueryBuilder

EndBefore - end before

func (*QueryBuilder) Equal

func (qb *QueryBuilder) Equal(path string, value interface{}) *QueryBuilder

Equal - equality filter ( `==` )

func (*QueryBuilder) GreaterThan

func (qb *QueryBuilder) GreaterThan(path string, value interface{}) *QueryBuilder

GreaterThan - range filter ( `>` )

func (*QueryBuilder) GreaterThanOrEqual

func (qb *QueryBuilder) GreaterThanOrEqual(path string, value interface{}) *QueryBuilder

GreaterThanOrEqual - range filter ( `>=` )

func (*QueryBuilder) In

func (qb *QueryBuilder) In(path string, value interface{}) *QueryBuilder

In - array filter ( `in` )

func (*QueryBuilder) LessThan

func (qb *QueryBuilder) LessThan(path string, value interface{}) *QueryBuilder

LessThan - range filter ( `<` )

func (*QueryBuilder) LessThanOrEqual

func (qb *QueryBuilder) LessThanOrEqual(path string, value interface{}) *QueryBuilder

LessThanOrEqual - range filter ( `<=` )

func (*QueryBuilder) Limit

func (qb *QueryBuilder) Limit(limit int) *QueryBuilder

Limit - limit

func (*QueryBuilder) NotEqual

func (qb *QueryBuilder) NotEqual(path string, value interface{}) *QueryBuilder

NotEqual - inequality filter ( `!=` )

func (*QueryBuilder) NotIn

func (qb *QueryBuilder) NotIn(path string, value interface{}) *QueryBuilder

NotIn - array filter ( `not-in` )

func (*QueryBuilder) Query

func (qb *QueryBuilder) Query() *firestore.Query

Query - return firestore.Query

func (*QueryBuilder) StartAfter

func (qb *QueryBuilder) StartAfter(docSnapshotOrFieldValues ...interface{}) *QueryBuilder

StartAfter - start after

func (*QueryBuilder) StartAt

func (qb *QueryBuilder) StartAt(docSnapshotOrFieldValues ...interface{}) *QueryBuilder

StartAt - start at

type QueryChainer

type QueryChainer struct {
	QueryGroup       []*Query
	OrderByDirection firestore.Direction
	Filter           Filter
	// contains filtered or unexported fields
}

QueryChainer - query chainer

func NewQueryChainer

func NewQueryChainer() *QueryChainer

NewQueryChainer - constructor

func (*QueryChainer) ArrayContains

func (qc *QueryChainer) ArrayContains(v interface{}) *QueryChainer

ArrayContains - `array-contains`

func (*QueryChainer) ArrayContainsAny

func (qc *QueryChainer) ArrayContainsAny(v interface{}) *QueryChainer

ArrayContainsAny - `array-contains-any`

func (*QueryChainer) Asc

func (qc *QueryChainer) Asc() *QueryChainer

Asc - `Asc`

func (*QueryChainer) BuildCursorQuery

func (qc *QueryChainer) BuildCursorQuery(q firestore.Query) firestore.Query

BuildCursor - build query for cursor

func (*QueryChainer) Desc

func (qc *QueryChainer) Desc() *QueryChainer

Desc - `Desc`

func (*QueryChainer) EndAt

func (qc *QueryChainer) EndAt(v ...interface{}) *QueryChainer

EndAt - end at

func (*QueryChainer) EndBefore

func (qc *QueryChainer) EndBefore(v ...interface{}) *QueryChainer

EndBefore - end before

func (*QueryChainer) Equal

func (qc *QueryChainer) Equal(v interface{}) *QueryChainer

Equal - `==`

func (*QueryChainer) Error

func (qc *QueryChainer) Error() error

Error - error

func (*QueryChainer) Filters

func (qc *QueryChainer) Filters(v interface{}, filterTypes ...FilterType) *QueryChainer

Filters - using `xim`

func (*QueryChainer) GreaterThan

func (qc *QueryChainer) GreaterThan(v interface{}) *QueryChainer

GreaterThan - `>`

func (*QueryChainer) GreaterThanOrEqual

func (qc *QueryChainer) GreaterThanOrEqual(v interface{}) *QueryChainer

GreaterThanOrEqual - `>=`

func (*QueryChainer) In

func (qc *QueryChainer) In(v interface{}) *QueryChainer

In - `in`

func (*QueryChainer) LessThan

func (qc *QueryChainer) LessThan(v interface{}) *QueryChainer

LessThan - `<`

func (*QueryChainer) LessThanOrEqual

func (qc *QueryChainer) LessThanOrEqual(v interface{}) *QueryChainer

LessThanOrEqual - `<=`

func (*QueryChainer) NotEqual

func (qc *QueryChainer) NotEqual(v interface{}) *QueryChainer

NotEqual - `!=`

func (*QueryChainer) NotIn

func (qc *QueryChainer) NotIn(v interface{}) *QueryChainer

NotIn - `not-in`

func (*QueryChainer) StartAfter

func (qc *QueryChainer) StartAfter(v ...interface{}) *QueryChainer

StartAt - start after

func (*QueryChainer) StartAt

func (qc *QueryChainer) StartAt(v ...interface{}) *QueryChainer

StartAt - start at

type Unique

type Unique struct {
	ID         string `firestore:"-"`
	Collection string
	Data       string
	Value      string
}

Unique - Collections for unique constraints

type UniqueMiddlewareKey

type UniqueMiddlewareKey struct{}

type UniqueRepositoryMiddleware

type UniqueRepositoryMiddleware interface {
	WrapError(ctx context.Context, err error, uniques []*Unique) error
}

UniqueRepositoryMiddleware - middleware

Notes

Bugs

  • there may be potential bugs

Jump to

Keyboard shortcuts

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