mgoclient

package
Version: v3.1.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeHtml

func EscapeHtml(origins ...interface{})

func HTMLEscape

func HTMLEscape(w io.Writer, b []byte)

HTMLEscape writes to w the escaped HTML equivalent of the plain text data b.

func HTMLEscapeString

func HTMLEscapeString(s string) string

HTMLEscapeString returns the escaped HTML equivalent of the plain text data s.

Types

type MgoCli

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

func NewFromConfig

func NewFromConfig(cfg MongoConfig) (*MgoCli, error)

func NewMgoCli

func NewMgoCli(host, port, usr, pwd, mechanism, database string) (*MgoCli, error)

func (*MgoCli) AddColumn

func (m *MgoCli) AddColumn(tableName string, column *storage.Column) error

新加字段, 表名,字段名,字段类型, 附加描述(是否为空, 默认值)

func (*MgoCli) Close

func (m *MgoCli) Close()

Close close mongo session

func (*MgoCli) CreateTable

func (m *MgoCli) CreateTable(tableName string) error

func (*MgoCli) DelByCondition

func (m *MgoCli) DelByCondition(cName string, condiction interface{}) error

按条件删除主句

func (*MgoCli) DropColumn

func (m *MgoCli) DropColumn(tableName, field string) error

func (*MgoCli) DropTable

func (m *MgoCli) DropTable(tableName string) error

func (*MgoCli) ExecSql

func (m *MgoCli) ExecSql(cmd interface{}) error

执行原始的sql语句,并不会返回数据, 只会是否执行出错

func (*MgoCli) GetCntByCondition

func (m *MgoCli) GetCntByCondition(cName string, condition interface{}) (cnt int, err error)

GetCntByCondition returns count number filter by condiction

func (*MgoCli) GetDBName

func (m *MgoCli) GetDBName() string

func (*MgoCli) GetIncID

func (m *MgoCli) GetIncID(cName string) (incID int64, err error)

GetIncID returns next sequence ID for cName collection

db.cc_idgenerator.findAndModify( {

	query:{_id: "sub" },
	update: {$inc:{SequenceID:1}},
	upsert:true,
	new:true
 }).sequence_value

func (*MgoCli) GetMutilByCondition

func (m *MgoCli) GetMutilByCondition(cName string, fields []string, condiction interface{}, result interface{}, sort string, start, limit int) error

GetMutilByCondition get multiple document by condiction

func (*MgoCli) GetOneByCondition

func (m *MgoCli) GetOneByCondition(cName string, fields []string, condiction interface{}, result interface{}) error

GetOneByCondition get one document by condiction

func (*MgoCli) GetSession

func (m *MgoCli) GetSession() interface{}

GetSession returns mongo session

func (*MgoCli) GetType

func (m *MgoCli) GetType() string

GetType 获取操作db的类

func (*MgoCli) HasFields

func (m *MgoCli) HasFields(tableName, field string) (bool, error)

func (*MgoCli) HasTable

func (m *MgoCli) HasTable(tableName string) (bool, error)

判断表是否存在

func (*MgoCli) Index

func (m *MgoCli) Index(tableName string, index *storage.Index) error

func (*MgoCli) Insert

func (m *MgoCli) Insert(cName string, data interface{}) (int, error)

Insert insert one document

func (*MgoCli) InsertMuti

func (m *MgoCli) InsertMuti(cName string, data ...interface{}) error

InsertMuti insert muti documents

func (*MgoCli) IsDuplicateErr

func (m *MgoCli) IsDuplicateErr(err error) bool

IsDuplicateErr returns whether err is duplicate error

func (*MgoCli) IsNotFoundErr

func (m *MgoCli) IsNotFoundErr(err error) bool

IsNotFoundErr returns whether err is not found error

func (*MgoCli) ModifyColumn

func (m *MgoCli) ModifyColumn(tableName, oldName, newColumn string) error

func (*MgoCli) Open

func (m *MgoCli) Open() error

Open open the connection

func (*MgoCli) Ping

func (m *MgoCli) Ping() error

Ping will ping the db server

func (*MgoCli) UpdateByCondition

func (m *MgoCli) UpdateByCondition(cName string, data, condition interface{}) error

UpdateByCondition update documents by condiction

type MongoConfig

type MongoConfig struct {
	Address      string
	User         string
	Password     string
	Database     string
	Port         string
	MaxOpenConns string
	MaxIdleConns string
	Mechanism    string
}

func NewMongoConfig

func NewMongoConfig(src map[string]string) *MongoConfig

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL