leafNoSql

package module
v0.0.0-...-0829b1e Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 6 Imported by: 6

README

NoSQL Interface

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection interface {
	Drop(ctx context.Context) error
	Indexes() IndexView
	Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mgo.Cursor, error)
	Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mgo.Cursor, error)
	FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mgo.SingleResult
	BulkWrite(ctx context.Context, models []mgo.WriteModel, opts ...*options.BulkWriteOptions) (*mgo.BulkWriteResult, error)
	CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
	DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mgo.DeleteResult, error)
	DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mgo.DeleteResult, error)
	UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mgo.UpdateResult, error)
	UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mgo.UpdateResult, error)
	InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mgo.InsertManyResult, error)
	InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mgo.InsertOneResult, error)
	FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) *mgo.SingleResult
	FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mgo.SingleResult
	Distinct(ctx context.Context, field string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
}

func NoopCollection

func NoopCollection() Collection

type Cursor

type Cursor interface {
	Next(context.Context) bool
	Close(ctx context.Context) error
	Decode(val interface{}) error
}

func NoopCursor

func NoopCursor() Cursor

type Database

type Database interface {
	Drop(ctx context.Context) error
	CreateCollection(ctx context.Context, name string) error
	HasCollection(ctx context.Context, name string) bool
	ListCollectionNames(ctx context.Context) ([]string, error)
	Collection(name string, opts ...*options.CollectionOptions) Collection
}

func NoopDatabase

func NoopDatabase() Database

type FindCallback

type FindCallback func(Cursor, error) error

type IndexView

type IndexView interface {
	List(ctx context.Context, opts ...*options.ListIndexesOptions) (Cursor, error)
	CreateMany(ctx context.Context, models []mgo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error)
	CreateOne(ctx context.Context, model mgo.IndexModel, opts ...*options.CreateIndexesOptions) (string, error)
	DropOne(ctx context.Context, name string, opts ...*options.DropIndexesOptions) (bson.Raw, error)
	DropAll(ctx context.Context, opts ...*options.DropIndexesOptions) (bson.Raw, error)
}

func NoopIndexView

func NoopIndexView() IndexView

type Mongo

type Mongo interface {
	FindOne(ctx context.Context, collection string, filter, object interface{}, options ...*options.FindOneOptions) error
	FindAll(ctx context.Context, collection string, filter interface{}, results interface{}, options ...*options.FindOptions) error
	Find(ctx context.Context, collection string, filter interface{}, callback FindCallback, options ...*options.FindOptions) error
	FindOneAndDelete(ctx context.Context, collection string, filter interface{}, options ...*options.FindOneAndDeleteOptions) error
	FindOneAndUpdate(ctx context.Context, collection string, filter, object interface{}, options ...*options.FindOneAndUpdateOptions) error
	Insert(ctx context.Context, collection string, object interface{}, options ...*options.InsertOneOptions) (*primitive.ObjectID, error)
	InsertMany(ctx context.Context, collection string, documents []interface{}, options ...*options.InsertManyOptions) ([]primitive.ObjectID, error)
	Update(ctx context.Context, collection string, filter, object interface{}, options ...*options.UpdateOptions) error
	UpdateMany(ctx context.Context, collection string, filter, object interface{}, options ...*options.UpdateOptions) error
	DeleteMany(ctx context.Context, collection string, filter interface{}, options ...*options.DeleteOptions) error
	Delete(ctx context.Context, collection string, filter interface{}, options ...*options.DeleteOptions) error
	BulkDocument(ctx context.Context, collection string, data []mgo.WriteModel) error
	Count(ctx context.Context, collection string, opts ...*options.CountOptions) (int64, error)
	CountWithFilter(ctx context.Context, collection string, filter interface{}, opts ...*options.CountOptions) (int64, error)
	Distinct(ctx context.Context, collection, field string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)

	Aggregate(ctx context.Context, collection string, pipeline interface{}, callback FindCallback, options ...*options.AggregateOptions) error
	Paginate(ctx context.Context, items interface{}, options PaginateOptions) (leafModel.PagingResponse, error)

	Indexes(collection string) IndexView
	Client() *mgo.Client
	DB() Database
	Ping(ctx context.Context) error
	Close(ctx context.Context) error
}

func NoopMongo

func NoopMongo() Mongo

type PaginateOptions

type PaginateOptions struct {
	// Paging
	Page  int
	Limit int
	Sort  []string

	// Database
	Collection string
	Filter     interface{}

	// Field Mapping
	FieldMap      map[string]string
	MapOrDefault  bool
	RequestFilter interface{}
}

Jump to

Keyboard shortcuts

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