storage

package
v0.0.0-...-c772d2a Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 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 MongoClient

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

func Connect

func Connect(ctx context.Context, url string, databaseName string, authMechanism string, username string, password string) *MongoClient

func (*MongoClient) Close

func (mc *MongoClient) Close(ctx context.Context) error

func (m *MongoCollection)CreateAccount()error

func (*MongoClient) CollectionInfo

func (mc *MongoClient) CollectionInfo(ctx context.Context, collection string) (resp core_interface.CollectionInfoResponse, err error)

返回数据库大小、索引大小、文档个数、索引个数

func (*MongoClient) CreateCollection

func (mc *MongoClient) CreateCollection(ctx context.Context, collectionName string) (err error)

func (*MongoClient) CreateIndex

func (mc *MongoClient) CreateIndex(ctx context.Context, collectionName string, indexName, column string) (createdIndexName string, err error)

创建单个索引

func (*MongoClient) Delete

func (mc *MongoClient) Delete(ctx context.Context, collectionName string, id string) (int64, error)

根据key value删除集合下所有符合条件的文档

func (*MongoClient) DropIndex

func (mc *MongoClient) DropIndex(ctx context.Context, collectionName string, indexName string) (err error)

index名字

func (*MongoClient) Insert

func (mc *MongoClient) Insert(ctx context.Context, collectionName string, val bson.M) (string, error)

插入一个文档

func (*MongoClient) Select

func (mc *MongoClient) Select(ctx context.Context, collectionName string,
	filter bson.M, sort bson.M, limit int64, skip int64) (response core_interface.SelectResponse, err error)

根据fileter查询文档

func (*MongoClient) SelectById

func (mc *MongoClient) SelectById(ctx context.Context, collectionName string, id string) (response core_interface.SelectResponse, err error)

根据主键查数据

func (*MongoClient) Update

func (mc *MongoClient) Update(ctx context.Context, collectionName string, filter, update bson.M, operation string) (count int64, err error)

TODO根据filter更新所有符合条件的文档

Jump to

Keyboard shortcuts

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