orm

package
v0.0.0-...-905eacb Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

implements the MongoCollectionDerived interface which is a derived interface from the MongoCollection interface. The MongoCollection interface defines the methods that can be used to interact with the MongoDB collection. The MongoCollectionDerived interface defines the methods that can be used to interact with the MongoDB collection in a more user-friendly way. The MongoORM struct is a struct that contains a MongoCollection interface and the name of the collection. The MongoORM struct is used to interact with the MongoDB collection in a more user-friendly way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoCollection

type MongoCollection interface {
	FindOne(ctx context.Context, filter interface{},
		opts ...*options.FindOneOptions) *mongo.SingleResult
	CountDocuments(ctx context.Context, filter interface{},
		opts ...*options.CountOptions) (int64, error)
	Find(ctx context.Context, filter interface{},
		opts ...*options.FindOptions) (*mongo.Cursor, error)
	InsertOne(ctx context.Context, document interface{},
		opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
	InsertMany(ctx context.Context, documents []interface{},
		opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
	UpdateOne(ctx context.Context, filter interface{}, update interface{},
		opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
	DeleteOne(ctx context.Context, filter interface{},
		opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
	Aggregate(ctx context.Context, filter interface{},
		opts ...*options.AggregateOptions) (*mongo.Cursor, error)
	Distinct(ctx context.Context, fieldName string, filter interface{},
		opts ...*options.DistinctOptions) ([]interface{}, error)
	BulkWrite(ctx context.Context, models []mongo.WriteModel,
		opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
	ReplaceOne(ctx context.Context, filter interface{},
		replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
	DeleteMany(ctx context.Context, filter interface{},
		opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
	Indexes() mongo.IndexView
	UpdateMany(ctx context.Context, filter interface{}, update interface{},
		opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
}

type MongoCollectionDerived

type MongoCollectionDerived interface {
	FindOne(ctx context.Context, target interface{}, filter interface{}, opts ...*options.FindOneOptions) error
	FindMany(ctx context.Context, target interface{}, filter interface{}, opts ...*options.FindOptions) error
	InsertOne(ctx context.Context, target interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
	InsertMany(ctx context.Context, target []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
	UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
	DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
	Aggregate(ctx context.Context, target interface{}, filter interface{}, opts ...*options.AggregateOptions) error
	Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
	BulkWrite(ctx context.Context, models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
	CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
	ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
	DeleteMany(ctx context.Context, filter interface{},
		opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
	Indexes() mongo.IndexView
	UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
}

type MongoORM

type MongoORM struct {
	Col     MongoCollection
	ColName string
	Logger  *zap.Logger
}

func (*MongoORM) Aggregate

func (mongoOrm *MongoORM) Aggregate(ctx context.Context, target interface{}, filter interface{}, opts ...*options.AggregateOptions) error

func (*MongoORM) BulkWrite

func (mongoOrm *MongoORM) BulkWrite(
	ctx context.Context, models []mongo.WriteModel, opts ...*options.BulkWriteOptions,
) (*mongo.BulkWriteResult, error)

func (*MongoORM) CountDocuments

func (mongoOrm *MongoORM) CountDocuments(
	ctx context.Context, filter interface{}, opts ...*options.CountOptions,
) (int64, error)

func (*MongoORM) DeleteMany

func (mongoOrm *MongoORM) DeleteMany(ctx context.Context, filter interface{},
	opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*MongoORM) DeleteOne

func (mongoOrm *MongoORM) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*MongoORM) Distinct

func (mongoOrm *MongoORM) Distinct(
	ctx context.Context,
	fieldName string,
	filter interface{},
	opts ...*options.DistinctOptions,
) ([]interface{}, error)

func (*MongoORM) FindMany

func (mongoOrm *MongoORM) FindMany(ctx context.Context, target interface{}, filter interface{}, opts ...*options.FindOptions) error

func (*MongoORM) FindOne

func (mongoOrm *MongoORM) FindOne(ctx context.Context, target interface{}, filter interface{}, opts ...*options.FindOneOptions) error

func (*MongoORM) Indexes

func (mongoOrm *MongoORM) Indexes() mongo.IndexView

func (*MongoORM) InsertMany

func (mongoOrm *MongoORM) InsertMany(ctx context.Context, items []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

func (*MongoORM) InsertOne

func (mongoOrm *MongoORM) InsertOne(ctx context.Context, target interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func (*MongoORM) ReplaceOne

func (mongoOrm *MongoORM) ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)

func (*MongoORM) UpdateMany

func (mongoOrm *MongoORM) UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*MongoORM) UpdateOne

func (mongoOrm *MongoORM) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

Jump to

Keyboard shortcuts

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