Documentation
¶
Index ¶
- Variables
- func AddCondition(filter interface{}, key string, condition interface{}) interface{}
- func And(filter interface{}, key string, f interface{}) interface{}
- func AppendE(f interface{}, elements ...bson.E) interface{}
- func AppendI(f interface{}, elements ...interface{}) interface{}
- func DToM(i interface{}) interface{}
- func GetE(f interface{}, k string) interface{}
- func IndentPrint(title string, data interface{})
- func IsTransactionAvailable(original string) bool
- func IsTransactionError(err error) bool
- type BatchConsumer
- type Client
- type ClientCollection
- type Collection
- func (c *Collection) Aggregate(ctx context.Context, pipeline []any, consumer Consumer, ...) error
- func (c *Collection) AggregateOne(ctx context.Context, pipeline []any, consumer Consumer, ...) error
- func (c *Collection) Client() *mongo.Collection
- func (c *Collection) Count(ctx context.Context, filter any) (int64, error)
- func (c *Collection) CountAggregation(ctx context.Context, pipeline []any) (int64, error)
- func (c *Collection) CreateOne(ctx context.Context, id string, doc any) error
- func (c *Collection) Find(ctx context.Context, filter any, consumer Consumer, ...) error
- func (c *Collection) FindOne(ctx context.Context, filter any, consumer Consumer, ...) error
- func (c *Collection) Indexes(ctx context.Context, keys, uniqueKeys []string) ([]string, []string, error)
- func (c *Collection) Indexes2(ctx context.Context, inputs ...Index) (IndexResult, error)
- func (c *Collection) Paginate(ctx context.Context, rawFilter any, s *usecasex.Sort, p *usecasex.Pagination, ...) (*usecasex.PageInfo, error)
- func (c *Collection) PaginateAggregation(ctx context.Context, pipeline []any, s *usecasex.Sort, p *usecasex.Pagination, ...) (*usecasex.PageInfo, error)
- func (c *Collection) PaginateProject(ctx context.Context, rawFilter any, s *usecasex.Sort, p *usecasex.Pagination, ...) (*usecasex.PageInfo, error)
- func (c *Collection) RemoveAll(ctx context.Context, f any) error
- func (c *Collection) RemoveOne(ctx context.Context, f any) error
- func (c *Collection) SaveAll(ctx context.Context, ids []string, updates []any) error
- func (c *Collection) SaveOne(ctx context.Context, id string, replacement any) error
- func (c *Collection) SetOne(ctx context.Context, id string, replacement any) error
- func (c *Collection) UpdateMany(ctx context.Context, filter, update any) error
- func (c *Collection) UpdateManyMany(ctx context.Context, updates []Update) error
- type Consumer
- type FuncConsumer
- type Index
- type IndexList
- type IndexResult
- type SimpleConsumer
- type SliceConsumer
- type SliceFuncConsumer
- type SliceRawFuncConsumer
- type Transaction
- type Tx
- type Update
Constants ¶
This section is empty.
Variables ¶
View Source
var NewClientCollection = NewCollection
Functions ¶
func AddCondition ¶
func AddCondition(filter interface{}, key string, condition interface{}) interface{}
func IndentPrint ¶
func IndentPrint(title string, data interface{})
func IsTransactionAvailable ¶
func IsTransactionError ¶
Types ¶
type BatchConsumer ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithDatabase ¶
func (*Client) Collection ¶
func (c *Client) Collection(col string) *Collection
func (*Client) Transaction ¶
func (c *Client) Transaction() usecasex.Transaction
func (*Client) WithCollection ¶
func (c *Client) WithCollection(col string) *Collection
WithCollection is deprecated
func (*Client) WithTransaction ¶
type ClientCollection ¶
type ClientCollection = Collection
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
func NewCollection ¶
func NewCollection(c *mongo.Collection) *Collection
func (*Collection) Aggregate ¶
func (c *Collection) Aggregate(ctx context.Context, pipeline []any, consumer Consumer, options ...*options.AggregateOptions) error
func (*Collection) AggregateOne ¶
func (c *Collection) AggregateOne(ctx context.Context, pipeline []any, consumer Consumer, options ...*options.AggregateOptions) error
func (*Collection) Client ¶
func (c *Collection) Client() *mongo.Collection
func (*Collection) CountAggregation ¶
func (*Collection) Find ¶
func (c *Collection) Find(ctx context.Context, filter any, consumer Consumer, options ...*options.FindOptions) error
func (*Collection) FindOne ¶
func (c *Collection) FindOne(ctx context.Context, filter any, consumer Consumer, options ...*options.FindOneOptions) error
func (*Collection) Indexes ¶
func (c *Collection) Indexes(ctx context.Context, keys, uniqueKeys []string) ([]string, []string, error)
Indexes creates and deletes indexes by keys declaratively
func (*Collection) Indexes2 ¶
func (c *Collection) Indexes2(ctx context.Context, inputs ...Index) (IndexResult, error)
Indexes creates and deletes indexes declaratively
func (*Collection) Paginate ¶
func (c *Collection) Paginate(ctx context.Context, rawFilter any, s *usecasex.Sort, p *usecasex.Pagination, consumer Consumer, opts ...*options.FindOptions) (*usecasex.PageInfo, error)
func (*Collection) PaginateAggregation ¶
func (c *Collection) PaginateAggregation(ctx context.Context, pipeline []any, s *usecasex.Sort, p *usecasex.Pagination, consumer Consumer, opts ...*options.AggregateOptions) (*usecasex.PageInfo, error)
func (*Collection) PaginateProject ¶
func (c *Collection) PaginateProject(ctx context.Context, rawFilter any, s *usecasex.Sort, p *usecasex.Pagination, consumer Consumer, opts ...*options.FindOptions) (*usecasex.PageInfo, error)
func (*Collection) UpdateMany ¶
func (c *Collection) UpdateMany(ctx context.Context, filter, update any) error
func (*Collection) UpdateManyMany ¶
func (c *Collection) UpdateManyMany(ctx context.Context, updates []Update) error
type FuncConsumer ¶
type Index ¶
type Index struct { Name string Key bson.D Unique bool ExpireAfterSeconds *int32 Filter bson.M `bson:"partialFilterExpression"` }
func IndexFromKey ¶
func IndexFromKeys ¶
func TTLIndexFromKey ¶
func (Index) Model ¶
func (i Index) Model() mongo.IndexModel
type IndexList ¶
type IndexList []Index
func (IndexList) AddNamePrefix ¶
func (IndexList) Models ¶
func (l IndexList) Models() []mongo.IndexModel
func (IndexList) NamesWithoutPrefix ¶
func (IndexList) RemoveDefaultIndex ¶
type IndexResult ¶
type IndexResult util.DiffResult[Index]
func (IndexResult) AddedNames ¶
func (i IndexResult) AddedNames() []string
func (IndexResult) DeletedNames ¶
func (i IndexResult) DeletedNames() []string
func (IndexResult) UpdatedNames ¶
func (i IndexResult) UpdatedNames() []string
type SimpleConsumer ¶
type SliceConsumer ¶
type SliceConsumer[T any] struct { Result []T // contains filtered or unexported fields }
type SliceFuncConsumer ¶
type SliceFuncConsumer[T, K any] struct { Result []K // contains filtered or unexported fields }
func NewSliceFuncConsumer ¶
func NewSliceFuncConsumer[T, K any](f func(t T) (K, error)) *SliceFuncConsumer[T, K]
type SliceRawFuncConsumer ¶
type SliceRawFuncConsumer[T any] struct { Result []T // contains filtered or unexported fields }
func NewSliceRawFuncConsumer ¶
func NewSliceRawFuncConsumer[T any](f func(t bson.Raw) (T, error)) *SliceRawFuncConsumer[T]
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func NewTransaction ¶
func NewTransaction(client *mongo.Client) *Transaction
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx implements usecasex.Tx, but note that it's not goroutine-safe.
func (*Tx) IsCommitted ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.