Documentation ¶
Index ¶
- Variables
- type DBHelper
- type FindOption
- func WithExactLabels() FindOption
- func WithFilters(filter map[string]interface{}) FindOption
- func WithLabels(labels map[string]string) FindOption
- func WithLimit(limit int64) FindOption
- func WithOffset(offset int64) FindOption
- func WithProjection(projection map[string]interface{}) FindOption
- func WithSort(sort map[string]int32) FindOption
- func WithTimeout(d time.Duration) FindOption
- type FindOptions
- type Init
- type Page
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DBService DBHelper DBInit Init )
services
Functions ¶
This section is empty.
Types ¶
type DBHelper ¶
type DBHelper interface { Aggregate(ctx context.Context, collname string, pipeline []map[string]interface{}, value interface{}) error CountDocuments(ctx context.Context, collname string, filter map[string]interface{}) (int64, error) CreateOne(ctx context.Context, collname string, rec interface{}) error CreateMany(ctx context.Context, collname string, recs ...interface{}) error FindOne(ctx context.Context, collname string, value interface{}, options ...FindOption) error FindOneAndDelete(ctx context.Context, collname string, filter map[string]interface{}, value interface{}, options ...FindOption) error List(ctx context.Context, collname string, value interface{}, options ...FindOption) (*Page, error) // $pull Pull(ctx context.Context, collname string, filter map[string]interface{}, value interface{}) error RemoveMany(ctx context.Context, collname string, filter map[string]interface{}) error // $unset Unmark(ctx context.Context, collname string, filter map[string]interface{}, value interface{}) error UpdateMany(ctx context.Context, collname string, filter interface{}, update interface{}) (*mongo.UpdateResult, error) UpdateOne(ctx context.Context, collname string, filter map[string]interface{}, value interface{}, options ...FindOption) error // 对 UpdateOne 的扩展,允许使用 $set 之外的操作符 UpdateOneMore(ctx context.Context, collname string, filter map[string]interface{}, value interface{}, options ...FindOption) error }
type FindOption ¶
type FindOption func(*FindOptions)
FindOption is functional option to find key value
func WithExactLabels ¶
func WithExactLabels() FindOption
WithExactLabels tell model service to return only one kv matches the labels
func WithProjection ¶
func WithProjection(projection map[string]interface{}) FindOption
WithProjection include or exclude fileds
func WithTimeout ¶
func WithTimeout(d time.Duration) FindOption
WithTimeout will return err if execution take too long
type FindOptions ¶
type FindOptions struct { ExactLabels bool Projection map[string]interface{} Filters map[string]interface{} Labels map[string]string Timeout time.Duration Offset int64 Limit int64 Sort map[string]int32 }
FindOptions is option to find key value
func NewDefaultFindOpts ¶
func NewDefaultFindOpts() FindOptions
NewDefaultFindOpts return default options
Click to show internal directories.
Click to hide internal directories.