lxDb

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionInsert = "insert"
	ActionFind   = "find"
	ActionUpdate = "update"
	ActionUpsert = "upsert"
	ActionRemove = "remove"
)

Variables

This section is empty.

Functions

func GetMongoDbConnection

func GetMongoDbConnection(url string) *mgo.Session

NewMongoDbConn, get a new db connection

Types

type AuditModel added in v0.4.3

type AuditModel struct {
	TimeStamp  time.Time   `json:"timestamp" bson:"timestamp"`
	Collection string      `json:"collection" bson:"collection"`
	Action     string      `json:"action" bson:"action"`
	User       interface{} `json:"user" bson:"user"`
	Data       interface{} `json:"data" bson:"data"`
}

func (*AuditModel) ToJson added in v0.4.3

func (am *AuditModel) ToJson() string

ToJson, convert model to json string for log

type ChangeInfo

type ChangeInfo struct {
	Updated int // Number of documents updated
	Removed int // Number of documents removed
	Matched int // Number of documents matched but not necessarily changed
}

ChangeInfo holds details about the outcome of an update operation.

type MongoDb

type MongoDb struct {
	Conn       *mgo.Session
	Name       string
	Collection string
}

Db struct for mongodb

func NewMongoDb

func NewMongoDb(connection *mgo.Session, dbName, collection string) *MongoDb

func (*MongoDb) AuditLog added in v0.4.3

func (db *MongoDb) AuditLog(action string, user, data interface{}) error

AuditLog log db audit

func (*MongoDb) Setup

func (db *MongoDb) Setup(indexes []mgo.Index) error

Setup create indexes for user collection.

type Options

type Options struct {
	Sort  string `json:"sort,omitempty"`
	Skip  int    `json:"skip"`
	Limit int    `json:"limit"`
	Count bool   `json:"count"`
}

Jump to

Keyboard shortcuts

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