lxDb

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = time.Second * 30
)

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 GetMongoDbConnection

func GetMongoDbConnection(url string) *mgo.Session

NewMongoDbConn, get a new db connection

func ToBsonDoc added in v0.8.0

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

ToBsonDoc, convert interface to bson.D

Types

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
}

/////////////////////////////////////////////// deprecated, Will be removed in a later version /////////////////////////////////////////////// ChangeInfo holds details about the outcome of an update operation.

type FindOptions added in v0.8.0

type FindOptions struct {
	Sort  map[string]int `json:"sort,omitempty"`
	Skip  int64          `json:"skip"`
	Limit int64          `json:"limit"`
}

FindOptions

func (*FindOptions) ToMongoCountOptions added in v0.8.0

func (fo *FindOptions) ToMongoCountOptions() *options.CountOptions

ToMongoCountOptions

func (*FindOptions) ToMongoFindOneOptions added in v0.8.0

func (fo *FindOptions) ToMongoFindOneOptions() *options.FindOneOptions

ToMongoFindOneOptions

func (*FindOptions) ToMongoFindOptions added in v0.8.0

func (fo *FindOptions) ToMongoFindOptions() *options.FindOptions

ToMongoFindOptions

type IBaseRepo added in v0.8.0

type IBaseRepo interface {
	InsertOne(collection string, doc interface{}, args ...interface{}) (interface{}, error)
	InsertMany(collection string, docs []interface{}, args ...interface{}) ([]interface{}, error)
	CountDocuments(collection string, filter interface{}, args ...interface{}) (int64, error)
	EstimatedDocumentCount(collection string, args ...interface{}) (int64, error)
	Find(collection string, filter interface{}, result interface{}, args ...interface{}) error
	FindOne(collection string, filter interface{}, result interface{}, args ...interface{}) error
	UpdateOne(collection string, filter interface{}, update interface{}, args ...interface{}) (*UpdateResult, error)
	UpdateMany(collection string, filter interface{}, update interface{}, args ...interface{}) (*UpdateResult, error)
	DeleteOne(collection string, filter interface{}, args ...interface{}) (int64, error)
	DeleteMany(collection string, filter interface{}, args ...interface{}) (int64, error)
}

func NewMongoBaseRepo added in v0.8.0

func NewMongoBaseRepo(db *mongo.Database) IBaseRepo

NewMongoBaseRepo, return base repo instance

type MongoDb

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

/////////////////////////////////////////////// deprecated, Will be removed in a later version /////////////////////////////////////////////// Db struct for mongodb

func NewMongoDb

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

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"`
}

type UpdateResult added in v0.8.0

type UpdateResult struct {
	MatchedCount  int64
	ModifiedCount int64
	UpsertedCount int64
	UpsertedID    interface{}
}

UpdateResult

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