lxDb

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = time.Second * 30
	Insert         = "insert"
	Update         = "update"
	Delete         = "delete"
)

Variables

This section is empty.

Functions

func GetMongoDbClient added in v0.8.0

func GetMongoDbClient(uri string) (client *mongo.Client, err error)

GetMongoDbClient, return new mongo driver client

func ToBsonDoc added in v0.8.0

func ToBsonDoc(v interface{}) (doc *bson.D, err error)

ToBsonDoc, convert interface to bson.D

func ToBsonMap added in v1.0.0

func ToBsonMap(v interface{}) (doc bson.M, err error)

ToBsonMap, convert interface to bson.M

Types

type AuditAuth added in v1.0.0

type AuditAuth struct {
	User interface{}
}

AuthAudit, auth user for audit

func SetAuditAuth added in v1.1.1

func SetAuditAuth(user interface{}) *AuditAuth

SetAuditAuthUser, returns AuditAuth with user

type DeleteManyResult added in v1.2.0

type DeleteManyResult struct {
	DeletedCount int64
}

type IBaseRepo added in v0.8.0

type IBaseRepo interface {
	CreateIndexes(indexes interface{}, args ...interface{}) ([]string, error)
	InsertOne(doc interface{}, args ...interface{}) (interface{}, error)
	InsertMany(docs []interface{}, args ...interface{}) (*InsertManyResult, error)
	CountDocuments(filter interface{}, args ...interface{}) (int64, error)
	EstimatedDocumentCount(args ...interface{}) (int64, error)
	Find(filter interface{}, result interface{}, args ...interface{}) error
	FindOne(filter interface{}, result interface{}, args ...interface{}) error
	UpdateOne(filter interface{}, update interface{}, args ...interface{}) error
	UpdateMany(filter interface{}, update interface{}, args ...interface{}) (*UpdateManyResult, error)
	DeleteOne(filter interface{}, args ...interface{}) error
	DeleteMany(filter interface{}, args ...interface{}) (*DeleteManyResult, error)
	GetCollection() interface{}
	GetDb() interface{}
	GetRepoName() string
}

IBaseRepo

func NewMongoBaseRepo added in v0.8.0

func NewMongoBaseRepo(collection *mongo.Collection, baseRepoAudit ...IBaseRepoAudit) IBaseRepo

NewMongoBaseRepo, return base repo instance

type IBaseRepoAudit added in v1.0.0

type IBaseRepoAudit interface {
	LogEntry(action string, user, data interface{}, timeout ...time.Duration) error
	LogEntries(entries []interface{}, timeout ...time.Duration) error
}

type InsertManyResult added in v1.2.0

type InsertManyResult struct {
	FailedCount int64
	InsertedIDs []interface{}
}

type NotFoundError added in v1.0.0

type NotFoundError struct {
	Message string
}

NotFoundError

func NewNotFoundError added in v1.0.0

func NewNotFoundError(message ...interface{}) *NotFoundError

NewApiPostError creates a new HTTPError instance.

func (*NotFoundError) Error added in v1.0.0

func (e *NotFoundError) Error() string

type SubIdName added in v1.2.0

type SubIdName struct {
	Name string
}

UpdateManySubIdName, id name for sub doc in filter

type UpdateManyResult added in v1.2.0

type UpdateManyResult struct {
	MatchedCount  int64
	ModifiedCount int64
	FailedCount   int64
	FailedIDs     []interface{}
	UpsertedCount int64
	UpsertedID    interface{}
}

Directories

Path Synopsis
Package lxDbMocks is a generated GoMock package.
Package lxDbMocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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