mgo

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObjectId

func ObjectId() primitive.ObjectID

func StringId

func StringId() string

Types

type Aggregate

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

func (*Aggregate) AddFields

func (a *Aggregate) AddFields(addFields bson.M) *Aggregate

func (*Aggregate) Bucket

func (a *Aggregate) Bucket(bucket bson.M) *Aggregate

func (*Aggregate) BucketAuto

func (a *Aggregate) BucketAuto(bucketAuto bson.M) *Aggregate

func (*Aggregate) CollStats

func (a *Aggregate) CollStats(collStats bson.M) *Aggregate

func (*Aggregate) Count

func (a *Aggregate) Count(count bson.M) *Aggregate

func (*Aggregate) Densify

func (a *Aggregate) Densify(densify bson.M) *Aggregate

func (*Aggregate) Facet

func (a *Aggregate) Facet(facet bson.M) *Aggregate

func (*Aggregate) Fill

func (a *Aggregate) Fill(fill bson.M) *Aggregate

func (*Aggregate) GeoNear

func (a *Aggregate) GeoNear(geoNear bson.M) *Aggregate

func (*Aggregate) GraphLookup

func (a *Aggregate) GraphLookup(graphLookup bson.M) *Aggregate

func (*Aggregate) Group

func (a *Aggregate) Group(group bson.M) *Aggregate

func (*Aggregate) IndexStats

func (a *Aggregate) IndexStats(indexStats bson.M) *Aggregate

func (*Aggregate) Limit

func (a *Aggregate) Limit(limit bson.M) *Aggregate

func (*Aggregate) List

func (a *Aggregate) List(data any) error

func (*Aggregate) Lookup

func (a *Aggregate) Lookup(lookup bson.M) *Aggregate

func (*Aggregate) Match

func (a *Aggregate) Match(match bson.M) *Aggregate

func (*Aggregate) Merge

func (a *Aggregate) Merge(merge bson.M) *Aggregate

func (*Aggregate) One

func (a *Aggregate) One(data any) error

func (*Aggregate) Out

func (a *Aggregate) Out(out bson.M) *Aggregate

func (*Aggregate) Project

func (a *Aggregate) Project(project bson.M) *Aggregate

func (*Aggregate) Redact

func (a *Aggregate) Redact(redact bson.M) *Aggregate

func (*Aggregate) ReplaceRoot

func (a *Aggregate) ReplaceRoot(replaceRoot bson.M) *Aggregate

func (*Aggregate) ReplaceWith

func (a *Aggregate) ReplaceWith(replaceWith bson.M) *Aggregate

func (*Aggregate) Sample

func (a *Aggregate) Sample(sample bson.M) *Aggregate

func (*Aggregate) Scopes

func (a *Aggregate) Scopes(scopes ...ScopeAggregate) *Aggregate

func (*Aggregate) Search

func (a *Aggregate) Search(search bson.M) *Aggregate

func (*Aggregate) SearchMeta

func (a *Aggregate) SearchMeta(searchMeta bson.M) *Aggregate

func (*Aggregate) Set

func (a *Aggregate) Set(set bson.M) *Aggregate

func (*Aggregate) SetWindowFields

func (a *Aggregate) SetWindowFields(setWindowFields bson.M) *Aggregate

func (*Aggregate) Skip

func (a *Aggregate) Skip(skip bson.M) *Aggregate

func (*Aggregate) Sort

func (a *Aggregate) Sort(sort bson.M) *Aggregate

func (*Aggregate) SortByCount

func (a *Aggregate) SortByCount(sortByCount bson.M) *Aggregate

func (*Aggregate) UnionWith

func (a *Aggregate) UnionWith(unionWith bson.M) *Aggregate

func (*Aggregate) Unset

func (a *Aggregate) Unset(unset bson.M) *Aggregate

func (*Aggregate) Unwind

func (a *Aggregate) Unwind(unwind bson.M) *Aggregate

type Client

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

func NewClient

func NewClient(ctx context.Context, opts Options) (*Client, error)

func (*Client) Database

func (c *Client) Database(name string) *Database

func (*Client) Transaction

func (c *Client) Transaction(fn func(sessionContext mongo.SessionContext) error) error

Transaction 提供了一个在 MongoDB 中执行事务的方法。 它接受一个函数作为参数,该函数接受一个 mongo.SessionContext 类型的参数并返回一个 error 类型的值。 如果函数返回一个非空的 error,事务将被回滚,否则事务将被提交。 如果在启动事务时出现错误,将返回该错误。 如果在提交或回滚事务时出现错误,将返回该错误。

type Database

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

func NewDatabase

func NewDatabase(cli *Client, name string) *Database

func (*Database) Model

func (d *Database) Model(m Model) *Table

func (*Database) Table

func (d *Database) Table(name string) *Table

type Filter

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

func (*Filter) Count

func (f *Filter) Count() (int64, error)

func (*Filter) DeleteMany

func (f *Filter) DeleteMany() error

func (*Filter) DeleteOne

func (f *Filter) DeleteOne() error

func (*Filter) Filter

func (f *Filter) Filter(key string, value any) *Filter

func (*Filter) Filters

func (f *Filter) Filters(filters bson.M) *Filter

func (*Filter) Limit

func (f *Filter) Limit(limit int64) *Filter

func (*Filter) List

func (f *Filter) List(data any) error

func (*Filter) One

func (f *Filter) One(data any) error

func (*Filter) Scopes

func (f *Filter) Scopes(scopes ...ScopeFilter) *Filter

func (*Filter) Skip

func (f *Filter) Skip(skip int64) *Filter

func (*Filter) Sort

func (f *Filter) Sort(sort any) *Filter

func (*Filter) UpdateMany

func (f *Filter) UpdateMany(update any) error

func (*Filter) UpdateOne

func (f *Filter) UpdateOne(update any) error

type Model

type Model interface {
	TableName() string
}

type ObjectID

type ObjectID = primitive.ObjectID

type Options

type Options struct {
	Uri string
}

type ScopeAggregate

type ScopeAggregate func(agg *Aggregate) *Aggregate

type ScopeFilter

type ScopeFilter func(f *Filter)

type Table

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

func NewTable

func NewTable(db *Database, name string) *Table

func (*Table) Aggregate

func (t *Table) Aggregate(ctx context.Context) *Aggregate

func (*Table) Drop

func (t *Table) Drop(ctx context.Context) (err error)

func (*Table) Filter

func (t *Table) Filter(ctx context.Context) *Filter

func (*Table) InsertMany

func (t *Table) InsertMany(ctx context.Context, data []any) (ids []any, err error)

func (*Table) InsertOne

func (t *Table) InsertOne(ctx context.Context, data any) (id any, err error)

Jump to

Keyboard shortcuts

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