db

package
v1.1.25 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection added in v1.1.22

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

Collection mongo-driver collection

func (*Collection) Count added in v1.1.22

func (c *Collection) Count(selector interface{}) (int64, error)

Count 获取与筛选器匹配的文档数

func (*Collection) Find added in v1.1.22

func (c *Collection) Find(filter interface{}) *Session

Find 按给定筛选器查找文档

func (*Collection) Insert added in v1.1.22

func (c *Collection) Insert(document interface{}) error

Insert 将单个文档插入集合

func (*Collection) InsertAll added in v1.1.22

func (c *Collection) InsertAll(documents []interface{}) error

InsertAll 插入提供的文档集

func (*Collection) InsertAllWithResult added in v1.1.22

func (c *Collection) InsertAllWithResult(documents []interface{}) (result *mongo.InsertManyResult, err error)

InsertAllWithResult 插入提供的文档集并返回插入的结果

func (*Collection) InsertWithResult added in v1.1.22

func (c *Collection) InsertWithResult(document interface{}) (result *mongo.InsertOneResult, err error)

InsertWithResult 在集合中插入一个文档,并返回插入一个结果

func (*Collection) Remove added in v1.1.22

func (c *Collection) Remove(selector interface{}) error

Remove 从集合中删除单个文档

func (*Collection) RemoveAll added in v1.1.22

func (c *Collection) RemoveAll(selector interface{}) error

RemoveAll 从集合中删除多个文档

func (*Collection) RemoveID added in v1.1.22

func (c *Collection) RemoveID(id interface{}) error

RemoveID 按id从集合中删除单个文档

func (*Collection) Update added in v1.1.22

func (c *Collection) Update(selector interface{}, update interface{}, upsert ...bool) error

Update 更新集合中的单个文档

func (*Collection) UpdateAll added in v1.1.22

func (c *Collection) UpdateAll(selector interface{}, update interface{}, upsert ...bool) (*mongo.UpdateResult, error)

UpdateAll 更新集合中的多个文档

func (*Collection) UpdateID added in v1.1.22

func (c *Collection) UpdateID(id interface{}, update interface{}) error

UpdateID 按id更新集合中的单个文档

func (*Collection) UpdateWithResult added in v1.1.22

func (c *Collection) UpdateWithResult(selector interface{}, update interface{}, upsert ...bool) (result *mongo.UpdateResult, err error)

UpdateWithResult 更新集合中的单个文档并返回更新结果

type Database added in v1.1.22

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

Database mongo-driver database

func (*Database) C added in v1.1.22

func (d *Database) C(collection string) *Collection

C 返回集合

func (*Database) CollectionNames added in v1.1.22

func (d *Database) CollectionNames() (names []string, err error)

CollectionNames 返回数据库中存在的所有集合名称

type Session added in v1.1.22

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

Session mongo session

func New added in v1.1.22

func New() *Session

New session

func (*Session) All added in v1.1.22

func (s *Session) All(result interface{}) error

All 查找全部

func (*Session) C added in v1.1.22

func (s *Session) C(collection string) *Collection

C 返回集合

func (*Session) Client added in v1.1.22

func (s *Session) Client() *mongo.Client

Client 返回客户端

func (*Session) Connect added in v1.1.22

func (s *Session) Connect() error

Connect 连接服务器

func (*Session) DB added in v1.1.22

func (s *Session) DB(db string) *Database

DB 返回表示命名数据库的值

func (*Session) Disconnect added in v1.1.25

func (s *Session) Disconnect()

Disconnect 断开连接

func (*Session) Limit added in v1.1.22

func (s *Session) Limit(limit int64) *Session

Limit 指定结果数的限制,负限制意味着返回一批.

func (*Session) One added in v1.1.22

func (s *Session) One(result interface{}) error

One 最多返回一个与模型匹配的文档

func (*Session) Ping added in v1.1.22

func (s *Session) Ping() error

Ping 验证客户端是否可以连接到拓扑。如果readPreference为nil,则将使用客户端的默认读取首选项。

func (*Session) SetPoolLimit added in v1.1.22

func (s *Session) SetPoolLimit(limit uint64)

SetPoolLimit 指定服务器连接池的最大值

func (*Session) SetUri added in v1.1.25

func (s *Session) SetUri(uri string)

SetUri 指定服务器连接uri

func (*Session) Skip added in v1.1.22

func (s *Session) Skip(skip int64) *Session

Skip 指定返回前要跳过的文档数。对于小于3.2的服务器版本,默认值为0

func (*Session) Sort added in v1.1.22

func (s *Session) Sort(sort interface{}) *Session

Sort 指定返回文档的顺序

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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