impl

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Asc  = 1
	Desc = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AggQuery

type AggQuery struct {
	*MongodbParam
	// contains filtered or unexported fields
}

func NewAggQuery

func NewAggQuery(tableName string) *AggQuery

func (*AggQuery) AddToSet

func (a *AggQuery) AddToSet(field string, alias ...interface{}) mongodb.IAggQuery

func (*AggQuery) Avg

func (a *AggQuery) Avg(field string, alias ...interface{}) mongodb.IAggQuery

func (*AggQuery) Find

func (a *AggQuery) Find(ctx context.Context, records interface{}) error

func (*AggQuery) FindOne

func (a *AggQuery) FindOne(ctx context.Context, record interface{}) error

func (*AggQuery) First

func (a *AggQuery) First(field interface{}, alias ...interface{}) mongodb.IAggQuery

func (*AggQuery) GroupBy

func (a *AggQuery) GroupBy(field interface{}, alias ...interface{}) mongodb.IAggQuery

func (*AggQuery) Having

func (a *AggQuery) Having(condition interface{}) mongodb.IAggQuery

func (*AggQuery) Last

func (a *AggQuery) Last(field interface{}, alias ...interface{}) mongodb.IAggQuery

func (*AggQuery) Num

func (a *AggQuery) Num(field string) mongodb.IAggQuery

func (*AggQuery) Push

func (a *AggQuery) Push(field interface{}, alias ...interface{}) mongodb.IAggQuery

func (*AggQuery) StdDevPop

func (a *AggQuery) StdDevPop(field string, alias ...interface{}) mongodb.IAggQuery

func (*AggQuery) StdDevSamp

func (a *AggQuery) StdDevSamp(field string, alias ...interface{}) mongodb.IAggQuery

func (*AggQuery) Sum

func (a *AggQuery) Sum(field string, alias ...interface{}) mongodb.IAggQuery

type Mongodb

type Mongodb struct {
}

func NewMongodb

func NewMongodb() *Mongodb

func (*Mongodb) Table

func (m *Mongodb) Table(tableName string) mongodb.ITable

type MongodbArgs

type MongodbArgs struct {
	Op           string                   `bson:"op" json:"op"`
	Docs         interface{}              `bson:"docs,omitempty" json:"docs,omitempty"`
	Query        interface{}              `bson:"query,omitempty" json:"query,omitempty"`
	Collection   string                   `bson:"collection,omitempty" json:"collection,omitempty"`
	Sort         map[string]int64         `bson:"sort,omitempty" json:"sort,omitempty"`
	Projection   interface{}              `bson:"projection,omitempty" json:"projection,omitempty"`
	Hint         interface{}              `bson:"hint,omitempty" json:"hint,omitempty"`
	Skip         int64                    `bson:"skip,omitempty" json:"skip,omitempty"`
	Limit        int64                    `bson:"limit,omitempty" json:"limit,omitempty"`
	ArrayFilters interface{}              `bson:"arrayFilters,omitempty" json:"arrayFilters,omitempty"`
	Upsert       *bool                    `bson:"upsert,omitempty" json:"upsert,omitempty"`
	Pipeline     []map[string]interface{} `bson:"pipeline,omitempty" json:"pipeline,omitempty"`
	Update       interface{}              `bson:"update,omitempty" json:"update,omitempty"`
	One          *bool                    `bson:"one,omitempty" json:"one,omitempty"`
	// Distinct
	Key string `bson:"key,omitempty" json:"key,omitempty"`
	// aggregate
	Aggregate bool `bson:"aggregate,omitempty" json:"aggregate,omitempty"`
}

func NewMongodbArgs

func NewMongodbArgs() *MongodbArgs

type MongodbParam

type MongodbParam struct {
	TableName string       `bson:"tableName" json:"tableName"`
	Args      *MongodbArgs `bson:"args" json:"args"`
	Err       error        `bson:"-" json:"-"`
}

func NewMongodbParam

func NewMongodbParam(tableName string) *MongodbParam

func (*MongodbParam) AddSort

func (p *MongodbParam) AddSort(field string, direct int64)

func (*MongodbParam) GetOp

func (a *MongodbParam) GetOp() string

func (*MongodbParam) SetAggregate

func (p *MongodbParam) SetAggregate(agg bool)

func (*MongodbParam) SetDocs

func (a *MongodbParam) SetDocs(docs interface{})

func (*MongodbParam) SetKey

func (p *MongodbParam) SetKey(key string)

func (*MongodbParam) SetLimit

func (p *MongodbParam) SetLimit(limit int64)

func (*MongodbParam) SetOffset

func (p *MongodbParam) SetOffset(offset int64)

func (*MongodbParam) SetOne

func (p *MongodbParam) SetOne(one bool)

func (*MongodbParam) SetOp

func (p *MongodbParam) SetOp(op OpType)

func (*MongodbParam) SetProjection

func (p *MongodbParam) SetProjection(projection interface{})

func (*MongodbParam) SetQuery

func (p *MongodbParam) SetQuery(condition interface{})

func (*MongodbParam) SetTableName

func (p *MongodbParam) SetTableName(tableName string)

func (*MongodbParam) SetUpdate

func (p *MongodbParam) SetUpdate(field2value interface{})

func (*MongodbParam) SetUpsert

func (p *MongodbParam) SetUpsert(upsert bool)

type OpType

type OpType int
const (
	OpType_Insert OpType = iota + 1
	OpType_Find
	OpType_FindOne
	OpType_Distinct
	OpType_Delete
	OpType_Count
	OpType_Update
	OpType_Upsert
	OpType_Aggregate
)

type Query

type Query struct {
	*MongodbParam
	// contains filtered or unexported fields
}

func NewQuery

func NewQuery(tableName string) *Query

func (*Query) BatchDelete

func (q *Query) BatchDelete(ctx context.Context) error

func (*Query) BatchUpdate

func (q *Query) BatchUpdate(ctx context.Context, record interface{}) error

func (*Query) Count

func (q *Query) Count(ctx context.Context) (int64, error)

func (*Query) Delete

func (q *Query) Delete(ctx context.Context) error

func (*Query) Find

func (q *Query) Find(ctx context.Context, records interface{}) error

func (*Query) FindOne

func (q *Query) FindOne(ctx context.Context, record interface{}) error

func (*Query) Limit

func (q *Query) Limit(limit int64) mongodb.IQuery

func (*Query) Offset

func (q *Query) Offset(offset int64) mongodb.IQuery

func (*Query) OrderBy

func (q *Query) OrderBy(fields ...string) mongodb.IQuery

func (*Query) OrderByDesc

func (q *Query) OrderByDesc(fields ...string) mongodb.IQuery

func (*Query) Project

func (q *Query) Project(projection interface{}) mongodb.IQuery

func (*Query) Update

func (q *Query) Update(ctx context.Context, record interface{}) error

func (*Query) Upsert

func (q *Query) Upsert(ctx context.Context, record interface{}) error

func (*Query) Where

func (q *Query) Where(condition interface{}, args ...interface{}) mongodb.IQuery

type Table

type Table struct {
	*MongodbParam
}

func NewTable

func NewTable(tableName string) *Table

func (*Table) BatchCreate

func (t *Table) BatchCreate(ctx context.Context, records interface{}) ([]primitive.ObjectID, error)

func (*Table) Create

func (t *Table) Create(ctx context.Context, record interface{}) (*structs.RecordOnlyId, error)

func (*Table) GroupBy

func (q *Table) GroupBy(field interface{}, alias ...interface{}) mongodb.IAggQuery

func (*Table) Where

func (t *Table) Where(condition interface{}, args ...interface{}) mongodb.IQuery

Jump to

Keyboard shortcuts

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