mongodbx

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectionExists

func CollectionExists(db *mongo.Database, coll string) (bool, error)

CollectionExists check if collection exists

func CollectionsMatchTimePattern

func CollectionsMatchTimePattern(db *mongo.Database, pattern string) ([]string, error)

func CountDocuments

func CountDocuments(client *mongo.Client, dsn, coll string) (int64, error)

func CreateIndex

func CreateIndex(coll *mongo.Collection, indexes map[string]int) error

CreateIndex creates indexes for coll

func CreateIndexIfNotExists

func CreateIndexIfNotExists(db *mongo.Database, collname string, indexes map[string]int) error

CreateIndexIfNotExists create indexes if collection doesn't exists

func ListCollections

func ListCollections(client *mongo.Client, dsn string) ([]string, error)

func ParseDsn

func ParseDsn(dsn string) (connstring.ConnString, error)

func TakeMongoClient

func TakeMongoClient(dsn string) (*mongo.Client, error)

func ToClickhouseTable

func ToClickhouseTable(dsn, db, tablename, indexes string, withTime bool) ([]string, string, error)

Types

type MongoModel

type MongoModel struct {
	Client     *mongo.Client
	AppName    string
	Dsn        string
	Database   string
	Collection string
	Type       reflect.Type
	Indexes    map[string]int

	FieldBsons []string
}

func MustNewMongoModel

func MustNewMongoModel(appName, dsn string, data interface{}) (*MongoModel, error)

func NewMongoModel

func NewMongoModel(appName, dsn string, data interface{}) (*MongoModel, error)

func (*MongoModel) All

func (m *MongoModel) All() (interface{}, error)

func (*MongoModel) BatchInsert

func (m *MongoModel) BatchInsert(vs interface{}) error

func (*MongoModel) DeleteWhere

func (m *MongoModel) DeleteWhere(where bson.M) (int64, error)

func (*MongoModel) Drop

func (m *MongoModel) Drop() error

Drop drop collection

func (*MongoModel) Insert

func (m *MongoModel) Insert(v interface{}) error

func (*MongoModel) MustAll

func (m *MongoModel) MustAll() interface{}

func (*MongoModel) QueryWhere

func (m *MongoModel) QueryWhere(where bson.M) (interface{}, error)

func (*MongoModel) UpdateSets

func (m *MongoModel) UpdateSets(where, sets bson.M) (int64, error)

Jump to

Keyboard shortcuts

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