interfaces

package
v0.0.0-...-b69267b Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deletable

type Deletable interface {

	// Delete deletes at most one document from a collection that matches a given filter.
	Delete(ctx context.Context, f Filter) (*mongo.DeleteResult, error)

	// DeleteMany deletes all documents from a collection that match a given filter.
	DeleteMany(ctx context.Context, f Filter) (*mongo.DeleteResult, error)

	// DeleteByID deletes at most one document from a collection that has a given id.
	DeleteByID(ctx context.Context, id interface{}) (*mongo.DeleteResult, error)
}

Deletable is the interface that wraps functions for deleting documents from a collection in a MongoDB database.

type Filter

type Filter map[string]interface{}

Filter makes the intent of filtering clearer.

type Findable

type Findable interface {

	// Find decodes all documents from a collection that match a given filter, and returns them.
	Find(ctx context.Context, f Filter) ([]interface{}, error)

	// FindByID decodes one document from a collection that has a given ID, and returns it.
	FindByID(ctx context.Context, id interface{}) (interface{}, error)

	// Exists returns whether at least one document matching a given filter exists in a collection.
	Exists(ctx context.Context, f Filter) (bool, error)

	// ExistsByID returns whether at least one document having a given ID exists in a collection.
	ExistsByID(ctx context.Context, id interface{}) (bool, error)
}

Findable is the interface that wraps functions for finding and checking the existence of document sin a collection in a MongoDB database.

type Insertable

type Insertable interface {

	// Insert decodes v into a document and inserts it into a collection.
	Insert(ctx context.Context, v interface{}) (*mongo.InsertOneResult, error)

	// InsertMany decodes every element in v and inserts it into a collection.
	InsertMany(ctx context.Context, v ...interface{}) (*mongo.InsertManyResult, error)
}

Insertable is the interface that wraps functions for inserting documents into a MongoDB database.

type Repository

type Repository interface {

	// See Findable
	Findable

	// See Insertable
	Insertable

	// See Updatable
	Updatable

	// See Deletable
	Deletable

	// Type returns the underlying type of the documents in
	// the collection the Repository is able to access.
	Type() reflect.Type
}

Repository is the interface that wraps interfaces providing CRUD operations for a MongoDB database.

type Updatable

type Updatable interface {

	// Update decodes changes into a value which is subsequently
	// used to update the first document matching f.
	Update(ctx context.Context, f Filter, changes map[string]interface{}) (*mongo.UpdateResult, error)

	// UpdateByID decodes changes into a value which is subsequently
	// used to update the first document having the given id.
	UpdateByID(ctx context.Context, id interface{}, changes map[string]interface{}) (*mongo.UpdateResult, error)
}

Updatable is the interface that wraps functions for updating documents in a collection in a MongoDB database.

Jump to

Keyboard shortcuts

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