Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Client *mongo.Client
View Source
var Database *mongo.Database
Functions ¶
func Connect ¶
func Connect() error
Connect initializes the MongoDB client using the MONGODB_URI environment variable.
func GenerateCustomNanoID ¶ added in v0.0.6
func GenerateMongoID ¶ added in v0.0.5
func GenerateNanoID ¶ added in v0.0.5
func GenerateNanoID() string
func GenerateNanoIdBySize ¶ added in v0.0.6
Types ¶
type MongoConfig ¶
type MongoConfig struct {
Username string
Password string
Host string
Port string
Database string
URI string
URIQuery string
}
var Config MongoConfig = MongoConfig{
Username: "",
Password: "",
Host: "",
Port: "",
Database: "",
URIQuery: "",
URI: "",
}
type ODM ¶ added in v0.0.2
type ODM[T any] struct { Collection *mongo.Collection CreateOne func(doc T, opts ...options.Lister[options.InsertOneOptions]) (*mongo.InsertOneResult, error) CreateMany func(docs []T, opts ...options.Lister[options.InsertManyOptions]) (*mongo.InsertManyResult, error) BulkWrite func(models []mongo.WriteModel) (*mongo.BulkWriteResult, error) FindOne func(filter bson.M, opts ...options.Lister[options.FindOneOptions]) (*T, error) FindMany func(filter bson.M, opts ...options.Lister[options.FindOptions]) ([]T, error) FindById func(id string, opts ...options.Lister[options.FindOneOptions]) (*T, error) List func(opts ...options.Lister[options.FindOptions]) ([]T, error) Count func(filter bson.M, opts ...options.Lister[options.CountOptions]) (int64, error) UpdateOne func(filter bson.M, update bson.M, opts ...options.Lister[options.UpdateOneOptions]) (*mongo.UpdateResult, error) UpdateMany func(filter bson.M, update bson.M, opts ...options.Lister[options.UpdateManyOptions]) (*mongo.UpdateResult, error) UpdateById func(id string, update bson.M, opts ...options.Lister[options.UpdateOneOptions]) (*mongo.UpdateResult, error) DeleteOne func(filter bson.M, opts ...options.Lister[options.DeleteOneOptions]) (*mongo.DeleteResult, error) DeleteMany func(filter bson.M, opts ...options.Lister[options.DeleteManyOptions]) (*mongo.DeleteResult, error) DeleteById func(id string, opts ...options.Lister[options.DeleteOneOptions]) (*mongo.DeleteResult, error) }
Click to show internal directories.
Click to hide internal directories.