mgo

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ID    = "_id"
	Name  = "name"
	Age   = "age"
	Sex   = "sex"
	Mtime = "mtime"
)

Variables

This section is empty.

Functions

func Collection

func Collection(db *mongo.Database) *mongo.Collection

Types

type DeleteBuilder

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

func Delete

func Delete(col *mongo.Collection) *DeleteBuilder

func (*DeleteBuilder) ByID

type FinderBuilder

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

func Find

func Find(col *mongo.Collection) *FinderBuilder

func (*FinderBuilder) All

func (f *FinderBuilder) All(ctx context.Context) ([]*User, error)

func (*FinderBuilder) Filter

func (f *FinderBuilder) Filter(filter ...primitive.E) *FinderBuilder

func (*FinderBuilder) Limit

func (f *FinderBuilder) Limit(l int64) *FinderBuilder

func (*FinderBuilder) One

func (f *FinderBuilder) One(ctx context.Context) (*User, error)

func (*FinderBuilder) Skip

func (f *FinderBuilder) Skip(s int64) *FinderBuilder

func (*FinderBuilder) Sort

func (f *FinderBuilder) Sort(field string, desc bool) *FinderBuilder

type InsertBuilder

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

func Create

func Create(col *mongo.Collection) *InsertBuilder

func (*InsertBuilder) Save

func (i *InsertBuilder) Save(ctx context.Context) error

func (*InsertBuilder) SetUsers

func (i *InsertBuilder) SetUsers(u ...*User) *InsertBuilder

type UpdateBuilder

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

func Update

func Update(col *mongo.Collection) *UpdateBuilder

func (*UpdateBuilder) ByID

func (*UpdateBuilder) SetAge

func (u *UpdateBuilder) SetAge(a int) *UpdateBuilder

func (*UpdateBuilder) SetID

func (*UpdateBuilder) SetMtime

func (u *UpdateBuilder) SetMtime(a time.Time) *UpdateBuilder

func (*UpdateBuilder) SetName

func (u *UpdateBuilder) SetName(a string) *UpdateBuilder

func (*UpdateBuilder) SetSex

func (u *UpdateBuilder) SetSex(a bool) *UpdateBuilder

type User

type User struct {
	ID    primitive.ObjectID `bson:"_id,omitempty"`
	Name  string
	Age   int
	Sex   bool
	Mtime time.Time
}

Jump to

Keyboard shortcuts

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