nosql

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(cfg *config.Env) (*mongo.Client, error)

Types

type NoSql

type NoSql struct {
	MongoClient *mongo.Client
	// contains filtered or unexported fields
}

func NewNoSql

func NewNoSql(cfg *config.Env, log *log.Logger, mongoClient *mongo.Client) *NoSql

func (*NoSql) Aggregate

func (pkg *NoSql) Aggregate(ctx context.Context, coll *mongo.Collection, pipeline interface{}, result interface{}, opts ...*options.AggregateOptions) error

Aggregate performs aggregation operations

func (*NoSql) BulkWrite

func (pkg *NoSql) BulkWrite(ctx context.Context, coll *mongo.Collection, operations []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)

BulkWrite performs bulk operations

func (*NoSql) Close

func (pkg *NoSql) Close(ctx context.Context) error

Close disconnects the MongoDB client

func (*NoSql) Collection

func (pkg *NoSql) Collection(databaseName, collectionName string) *mongo.Collection

Collection returns a handle for a MongoDB collection

func (*NoSql) CountDocuments

func (pkg *NoSql) CountDocuments(ctx context.Context, coll *mongo.Collection, filter interface{}, opts ...*options.CountOptions) (int64, error)

CountDocuments counts documents matching the filter

func (*NoSql) CreateIndex

func (pkg *NoSql) CreateIndex(ctx context.Context, coll *mongo.Collection, keys interface{}, opts *options.IndexOptions) (string, error)

CreateIndex creates an index on the collection

func (*NoSql) DeleteMany

func (pkg *NoSql) DeleteMany(ctx context.Context, coll *mongo.Collection, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

DeleteMany deletes multiple documents

func (*NoSql) DeleteOne

func (pkg *NoSql) DeleteOne(ctx context.Context, coll *mongo.Collection, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

DeleteOne deletes a single document

func (*NoSql) Find

func (pkg *NoSql) Find(ctx context.Context, coll *mongo.Collection, filter interface{}, results interface{}, opts ...*options.FindOptions) error

Find finds multiple documents

func (*NoSql) FindOne

func (pkg *NoSql) FindOne(ctx context.Context, coll *mongo.Collection, filter interface{}, result interface{}, opts ...*options.FindOneOptions) error

FindOne finds a single document

func (*NoSql) HealthCheck

func (pkg *NoSql) HealthCheck(ctx context.Context) error

HealthCheck verifies the MongoDB connection

func (*NoSql) InsertMany

func (pkg *NoSql) InsertMany(ctx context.Context, coll *mongo.Collection, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

InsertMany inserts multiple documents

func (*NoSql) InsertOne

func (pkg *NoSql) InsertOne(ctx context.Context, coll *mongo.Collection, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

InsertOne inserts a single document

func (*NoSql) ReplaceOne

func (pkg *NoSql) ReplaceOne(ctx context.Context, coll *mongo.Collection, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)

ReplaceOne replaces a single document

func (*NoSql) UpdateMany

func (pkg *NoSql) UpdateMany(ctx context.Context, coll *mongo.Collection, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateMany updates multiple documents

func (*NoSql) UpdateOne

func (pkg *NoSql) UpdateOne(ctx context.Context, coll *mongo.Collection, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateOne updates a single document

func (*NoSql) Watch

func (pkg *NoSql) Watch(ctx context.Context, coll *mongo.Collection, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)

Watch monitors changes in the collection

Jump to

Keyboard shortcuts

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