data

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoDocuments = errors.New("no documents in result")

Functions

This section is empty.

Types

type ArrayFilters

type ArrayFilters struct {
	Filters []interface{} // The filters to apply
}

type BulkUpdateOne

type BulkUpdateOne struct {
	Filter interface{}
	Data   interface{}
}

type IncrementOperator

type IncrementOperator struct {
	Inc interface{} `json:"$inc" bson:"$inc"`
}

type QueryResult

type QueryResult interface {
	Next() bool
	Decode(v interface{}) error
	Error() error
	Close()
}

type QuerySingleResult

type QuerySingleResult interface {
	Decode(v interface{}) error
	NoResult() bool
	Error() error
}

type Repository

type Repository interface {
	Save(collectionName string, data interface{}) <-chan RepositoryResult
	SaveMany(collectionName string, data []interface{}) <-chan RepositoryResult
	Aggregate(collectionName string, pipeline interface{}) <-chan QueryResult
	Find(collectionName string, filter interface{}, limit int64, skip int64, sort map[string]int) <-chan QueryResult
	FindOne(collectionName string, filter interface{}) <-chan QuerySingleResult
	Update(collectionName string, filter interface{}, data interface{}, opts ...*UpdateOptions) <-chan RepositoryResult
	UpdateMany(collectionName string, filter interface{}, data interface{}, opts ...*UpdateOptions) <-chan RepositoryResult
	BulkUpdateOne(collectionName string, bulkData []BulkUpdateOne) <-chan RepositoryResult
	Delete(collectionName string, filter interface{}, justOne bool) <-chan RepositoryResult
	CreateIndex(collectionName string, indexes map[string]interface{}) <-chan error
}

type RepositoryResult

type RepositoryResult struct {
	Error  error
	Result interface{}
}

RepositoryResult is a struct to wrap repository result so its easy to use it in channel

type SearchOperator

type SearchOperator struct {
	Search string `json:"$search" bson:"$search"`
}

type TextOperator

type TextOperator struct {
	Text SearchOperator `json:"$text" bson:"$text"`
}

type UpdateOperator

type UpdateOperator struct {
	Set interface{} `json:"$set" bson:"$set"`
}

type UpdateOptions

type UpdateOptions struct {
	ArrayFilters             *ArrayFilters // A set of filters specifying to which array elements an update should apply
	BypassDocumentValidation *bool         // If true, allows the write to opt-out of document level validation
	Upsert                   *bool         // When true, creates a new document if no document matches the query
}

UpdateOptions

func MergeUpdateOptions

func MergeUpdateOptions(opts ...*UpdateOptions) *UpdateOptions

MergeUpdateOptions combines the argued UpdateOptions into a single UpdateOptions in a last-one-wins fashion

func Update

func Update() *UpdateOptions

Update returns a pointer to a new UpdateOptions

func (*UpdateOptions) SetArrayFilters

func (uo *UpdateOptions) SetArrayFilters(af ArrayFilters) *UpdateOptions

SetArrayFilters specifies a set of filters specifying to which array elements an update should apply

func (*UpdateOptions) SetBypassDocumentValidation

func (uo *UpdateOptions) SetBypassDocumentValidation(b bool) *UpdateOptions

SetBypassDocumentValidation allows the write to opt-out of document level validation.

func (*UpdateOptions) SetUpsert

func (uo *UpdateOptions) SetUpsert(b bool) *UpdateOptions

SetUpsert allows the creation of a new document if not document matches the query

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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