Version: v1.0.4 Latest Latest

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

Go to latest
Published: Feb 9, 2020 License: AGPL-3.0 Imports: 8 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type DBClient

type DBClient interface {
	// contains filtered or unexported methods

DBClient : General Database client interface, reserved for future adopt.

type MongoDB

type MongoDB struct {
	DbConn         *mongo.Client
	DbURI          string
	DbColl         mongo.Collection
	DefaultDB      string
	DefaultColl    string
	DefaultTimeout time.Time

MongoDB : Connection Pool and Info

var (
	GlobalMGC  *mongo.Client
	GlobalMDBC MongoDB

MongoDB related global var to avoid lifetime problem.

func (*MongoDB) ConnNCheck

func (mdbc *MongoDB) ConnNCheck(dbCliOption interface{}) error

ConnNCheck : already implemented monitoring and checking

func (*MongoDB) InitMDBCOptions

func (mdbc *MongoDB) InitMDBCOptions() *options.ClientOptions

InitMDBCOptions : trying to create a db client with user-specified config in order to build a conn pool

func (MongoDB) ItemCreate

func (mdbc MongoDB) ItemCreate(inputdata interface{}) error

ItemCreate : push a userdata into mongodb

func (MongoDB) ItemDelete

func (mdbc MongoDB) ItemDelete(filter1 interface{}) error

ItemDelete : delete a item according to specific condition rather than objectid

func (MongoDB) ItemRead

func (mdbc MongoDB) ItemRead(filter1 interface{}) (UserData, error)

ItemRead : read from database, serialized into userdata type

func (MongoDB) ItemUpdate

func (mdbc MongoDB) ItemUpdate(filter1 interface{}, change1 interface{}) error

ItemUpdate : directly use bson schema to update document in the library

type UserData

type UserData struct {
	WaitVerify   bool                 `bson:"waitVerify" json:"waitVerify"`
	ReadThenBurn bool                 `bson:"readThenBurn" json:"readThenBurn"`
	ShortID      string               `bson:"shortId" json:"shortId"`
	UserIP       primitive.Decimal128 `bson:"userIP" json:"userIP"`
	ExpireAt     primitive.DateTime   `bson:"expireAt" json:"expireAt"`
	Data         primitive.Binary     `bson:"data" json:"data"`
	PwdIsSet     bool                 `bson:"pwdIsSet" json:"pwdIsSet"`
	Password     string               `bson:"passwd" json:"passwd"`

UserData : user uploaded data general structure

func (UserData) EqualsTo

func (dt UserData) EqualsTo(comparedto UserData) bool

EqualsTo : check user-defined object and type equal or not, self-override of operation ==

Source Files

Jump to

Keyboard shortcuts

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