database

package module
v0.0.0-...-433fd72 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: GPL-2.0 Imports: 9 Imported by: 0

README

Database Package Modules


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MongoConnect

func MongoConnect(uri, dbname string, timeout time.Duration) (*mongo.Database, error)

MongoConnect : create a new connection to mongodb

Example :

db, err := MongoConnect("mongodb://localhost:27017/testDB", "testDB", 30*time.Second)

if err != nil {
	log.Fatal(err)
}
if _, err := db.ListCollectionSpecifications(ctx, bson.M{}); err != nil {
	 log.Fatal(err)
}

func MongoInit

func MongoInit(db *mongo.Database, collectionName string, index ...MongoIndex) *mongo.Collection

MongoInit : make collection with indexes

func ParseMongoURI

func ParseMongoURI(uri string) (dbURI, dbname string)

Types

type MongoIndex

type MongoIndex struct {
	Keys   interface{}
	Unique bool
}

func MakeMongoIndex

func MakeMongoIndex(keys bson.D, unique bool) MongoIndex

MakeMongoIndex - make MongoIndex by keys

Directories

Path Synopsis
internal
mongo-driver/internal/randutil
Package randutil provides common random number utilities.
Package randutil provides common random number utilities.
mongo-driver/internal/randutil/rand
Package rand implements pseudo-random number generators.
Package rand implements pseudo-random number generators.
mongo-driver/mongo/writeconcern
Package writeconcern defines write concerns for MongoDB operations.
Package writeconcern defines write concerns for MongoDB operations.

Jump to

Keyboard shortcuts

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