mongoc

package
v0.0.0-...-7378411 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionMissing = errors.New("session missing")

ErrSessionMissing session missing

Functions

This section is empty.

Types

type Client

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

Client implement client.DALRDB interface

func NewClient

func NewClient(uri string) (*Client, error)

NewClient returns new RDB

func (*Client) Abort

func (c *Client) Abort(context.Context) error

Abort 取消事务

func (*Client) Clone

func (c *Client) Clone() dal.RDB

Clone return the new client

func (*Client) Close

func (c *Client) Close() error

Close replica client

func (*Client) Commit

func (c *Client) Commit(context.Context) error

Commit 提交事务

func (*Client) CreateTable

func (c *Client) CreateTable(collName string) error

CreateTable 创建集合

func (*Client) DropTable

func (c *Client) DropTable(collName string) error

DropTable 移除集合

func (*Client) HasTable

func (c *Client) HasTable(collName string) (bool, error)

HasTable 判断是否存在集合

func (*Client) IsDuplicatedError

func (c *Client) IsDuplicatedError(err error) bool

IsDuplicatedError interface compatibility

func (*Client) IsNotFoundError

func (c *Client) IsNotFoundError(err error) bool

IsNotFoundError interface compatibility

func (*Client) NextSequence

func (c *Client) NextSequence(ctx context.Context, sequenceName string) (uint64, error)

NextSequence 获取新序列号(非事务)

func (*Client) Ping

func (c *Client) Ping() error

Ping replica client

func (*Client) StartTransaction

func (c *Client) StartTransaction(ctx context.Context) (dal.RDB, error)

StartTransaction 开启新事务

func (*Client) Table

func (c *Client) Table(collName string) dal.Table

Table collection operation

func (*Client) TxnInfo

func (c *Client) TxnInfo() *types.Transaction

TxnInfo 当前事务信息,用于事务发起者往下传递

type Collection

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

Collection implement client.Collection interface

func (*Collection) AddColumn

func (c *Collection) AddColumn(ctx context.Context, column string, value interface{}) error

AddColumn 添加字段

func (*Collection) CreateIndex

func (c *Collection) CreateIndex(ctx context.Context, index dal.Index) error

CreateIndex 创建索引

func (*Collection) Delete

func (c *Collection) Delete(ctx context.Context, filter dal.Filter) error

Delete 删除数据

func (*Collection) DropColumn

func (c *Collection) DropColumn(ctx context.Context, field string) error

DropColumn 移除字段

func (*Collection) DropIndex

func (c *Collection) DropIndex(ctx context.Context, indexName string) error

DropIndex 移除索引

func (*Collection) Find

func (c *Collection) Find(filter dal.Filter) dal.Find

Find 查询多个并反序列化到 Result

func (*Collection) Indexes

func (c *Collection) Indexes(ctx context.Context) ([]dal.Index, error)

Indexes 查询索引

func (*Collection) Insert

func (c *Collection) Insert(ctx context.Context, docs interface{}) error

Insert 插入数据, docs 可以为 单个数据 或者 多个数据

func (*Collection) RenameColumn

func (c *Collection) RenameColumn(ctx context.Context, oldName, newColumn string) error

RenameColumn 重命名字段

func (*Collection) Update

func (c *Collection) Update(ctx context.Context, filter dal.Filter, doc interface{}) error

Update 更新数据

type Find

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

Find define a find operation

func (*Find) All

func (f *Find) All(ctx context.Context, result interface{}) error

All 查询多个

func (*Find) Count

func (f *Find) Count(ctx context.Context) (uint64, error)

Count 统计数量(非事务)

func (*Find) Fields

func (f *Find) Fields(fields ...string) dal.Find

Fields 查询字段

func (*Find) Limit

func (f *Find) Limit(limit uint64) dal.Find

Limit 查询限制

func (*Find) One

func (f *Find) One(ctx context.Context, result interface{}) error

One 查询一个

func (*Find) Sort

func (f *Find) Sort(sort string) dal.Find

Sort 查询排序

func (*Find) Start

func (f *Find) Start(start uint64) dal.Find

Start 查询上标

Jump to

Keyboard shortcuts

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