db

package
v0.0.0-...-2c71c5b Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect() *sql.DB

Connect : mysql db connect function.

Types

type Configure

type Configure struct {
	Mysqldbhost     string `json:"mysqldbhost"`
	Mysqldbport     string `json:"mysqldbport"`
	Mysqldbname     string `json:"mysqldbname"`
	Mysqldbusername string `json:"mysqldbusername"`
	Mysqldbpassword string `json:"mysqldbpassword"`
}

Configure : define mysql struct

type MongoDB

type MongoDB struct {
	Mongohost string `json:"mongohost"`
	Mongoport string `json:"mongoport"`
	DBName    string `json:"dbname"`
}

MongoDB define mongo db instance

func (MongoDB) Conn

func (db MongoDB) Conn() (*mgo.Session, string, error)

Conn connect mongo db.

type MongoHelper

type MongoHelper struct {
	Session    *mgo.Session
	DB         string
	Collection string
}

MongoHelper is the API client that performs all operations

func NewMongoHelper

func NewMongoHelper() MongoHelper

NewMongoHelper initializes a new mongo helper object.

func (MongoHelper) Insert

func (mongoHelper MongoHelper) Insert(ob interface{}) error

Insert insert one record in db

func (MongoHelper) QueryAll

func (mongoHelper MongoHelper) QueryAll(queryCondition interface{}, ob []interface{}) (result []interface{})

QueryAll is query all record by condition, return a interface.

func (MongoHelper) QueryOne

func (mongoHelper MongoHelper) QueryOne(queryCondition interface{}, ob interface{}) (code int, result interface{})

QueryOne query info by condition return one record.

func (MongoHelper) Update

func (mongoHelper MongoHelper) Update(colQuerier interface{}, update interface{}) bool

Update is update the entry by latest changed. args: cName to set the collection name. colQuerier to set the query collection condition. update to set the update object.

Jump to

Keyboard shortcuts

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