mongo

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPage = &Page{Limit: 10, Skip: 0, Sort: bson.M{"_id": -1}}

Functions

This section is empty.

Types

type Collection

type Collection struct {
	Client     *MongoClient
	Collection *mongo.Collection
	ColName    string
}

func NewCollection

func NewCollection(mc *MongoClient, colName string) *Collection

func (*Collection) Count

func (m *Collection) Count(filter interface{}) (int64, error)

func (*Collection) Delete

func (m *Collection) Delete(filter interface{}) (int64, error)

func (*Collection) Find

func (m *Collection) Find(p *Page, filter interface{}, result interface{}) error

func (*Collection) FindById

func (m *Collection) FindById(id string, result interface{}) error

func (*Collection) FindOne

func (m *Collection) FindOne(filter interface{}, result interface{}) error

func (*Collection) Insert

func (m *Collection) Insert(docs ...interface{}) ([]interface{}, error)

func (*Collection) Update

func (m *Collection) Update(filter, update interface{}) (int64, error)

type MongoClient

type MongoClient struct {
	Context context.Context
	Client  *mongo.Client
	DBCon   *mongo.Database
	Session mongo.Session
}

type MongoConfig

type MongoConfig struct {
	Type            MongoType          `json:"type"`
	URI             string             `json:"uri"`
	DBName          string             `json:"dbName"`
	Standalone      StandaloneConfig   `json:"standalone"`
	ReplicaSet      ReplicaSetConfig   `json:"replicaSet"`
	ShardCluster    ShardClusterConfig `json:"shardCluster"`
	MaxPoolSize     uint64             `json:"maxPoolSize"`
	MinPoolSize     uint64             `json:"minPoolSize"`
	MaxConnIdleTime time.Duration      `json:"maxConnIdleTime"`
	SocketTimeout   time.Duration      `json:"socketTimeout"`
}

func GetDefaultMongoConfig

func GetDefaultMongoConfig() *MongoConfig

func GetMongoConfig

func GetMongoConfig(key string) *MongoConfig

func (*MongoConfig) NewClient

func (mongoConfig *MongoConfig) NewClient() *MongoClient

type MongoType

type MongoType int
const (
	MongoStandalone MongoType = iota
	MongoReplicaSet
	MongoShardCluster
)

type Page

type Page struct {
	Limit int64
	Skip  int64
	Sort  bson.M
}

type ReplicaSetConfig

type ReplicaSetConfig struct {
	ReplicaName string `json:"replicaName"`
}

type ShardClusterConfig

type ShardClusterConfig struct {
}

type StandaloneConfig

type StandaloneConfig struct {
}

Jump to

Keyboard shortcuts

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