lxDb

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var ErrIndexConvert = errors.New("can't convert index models")

Error by convert index model

View Source
var ErrNotFound = errors.New("not found")

Not Found error

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 AuditEntry added in v1.7.0

type AuditEntry struct {
	Collection string      `json:"collection"`
	Action     string      `json:"action"`
	User       interface{} `json:"user"`
	Data       interface{} `json:"data"`
}

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
	FindOneAndDelete(filter interface{}, result interface{}, args ...interface{}) error
	FindOneAndReplace(filter, replacement, result interface{}, args ...interface{}) error
	FindOneAndUpdate(filter, update, 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
	SetLocale(code string)
	Aggregate(pipeline interface{}, result interface{}, args ...interface{}) error
}

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 {
	Send(elem interface{})
	IsActive() bool
}

type InsertManyResult added in v1.2.0

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

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