mongo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

README

neuron-mgo

Neuron Model Mongo Repository

Documentation

Index

Constants

View Source
const (
	ReplicaSetHostsKey = "replica_set_hosts"
	ApplicationNameKey = "application_name"
)

config.Repository.Options keys constants

Variables

This section is empty.

Functions

func RegisterFilterOperator

func RegisterFilterOperator(o *filters.Operator)

RegisterFilterOperator registers operator with the BSONizer function

func StringDecoderValue

func StringDecoderValue(dctx bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error

StringDecoderValue is the value decoder for the string fields

Types

type Config

type Config struct {
	*config.Repository

	// Hosts are the replica set hosts
	Hosts []string

	// ReplicaSetName is the name of the replica set
	ReplicaSetName string

	// ApplicationName is the name used in the mongodb logs for the specific client
	ApplicationName string

	// Options are the client options
	Options *options.ClientOptions
	// contains filtered or unexported fields
}

Config is the mongo db repository configuration struct

func NewConfig

func NewConfig(cfgRepo *config.Repository) (*Config, error)

NewConfig creates new repository config

func (*Config) Connection

func (c *Config) Connection() (*mongo.Client, error)

Connection creates new mongo client connection

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the config

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

Factory is the MongoDB - neuron repository factory

func New

func New() *Factory

New creates new mongo.Factory

func (*Factory) Close

func (f *Factory) Close(ctx context.Context, done chan<- interface{})

Close closes the repository instances

func (*Factory) New

New create new Mongo repository for the provided model struct

func (*Factory) RepositoryName

func (f *Factory) RepositoryName() string

RepositoryName gets the Factory repository names Implements repository.Repository interface

type Repository

type Repository struct {
	// Client is the mongodb connection client
	Client *mongo.Client

	// Config contains all the connection configurations
	Config *Config
	// contains filtered or unexported fields
}

Repository is the MongoDB - Neuron repository

func (*Repository) Begin

func (r *Repository) Begin(ctx context.Context, s *query.Scope) error

Begin uses the mongo repository to create the query scope value Implements query.Beginer interface

func (*Repository) Close

func (r *Repository) Close(ctx context.Context) error

Close closes the repository active connections

func (*Repository) Commit

func (r *Repository) Commit(ctx context.Context, s *query.Scope) error

Commit uses the mongo repository to create the query scope value Implements query.Commiter interface

func (*Repository) Create

func (r *Repository) Create(ctx context.Context, s *query.Scope) error

Create uses the mongo repository to create the query scope value Implements query.Creater interface

func (*Repository) CreateMany

func (r *Repository) CreateMany(ctx context.Context, s *query.Scope) error

CreateMany inserts multiple instances of given scope values Implements query.ManyCreater interface

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, s *query.Scope) error

Delete uses the mongo repository to create the query scope value Implements query.Deleter interface

func (*Repository) Get

func (r *Repository) Get(ctx context.Context, s *query.Scope) error

Get uses the mongo repository to create the query scope value Implements query.Geter interface

func (*Repository) List

func (r *Repository) List(ctx context.Context, s *query.Scope) error

List uses the mongo repository to create the query scope value Implements query.Lister interface

func (*Repository) Patch

func (r *Repository) Patch(ctx context.Context, s *query.Scope) error

Patch uses the mongo repository to create the query scope value Implements query.Patcher interface

func (*Repository) RepositoryName

func (r *Repository) RepositoryName() string

RepositoryName returns the repository name for the mongo repository Implements repository.Repository interface

func (*Repository) Rollback

func (r *Repository) Rollback(ctx context.Context, s *query.Scope) error

Rollback uses the mongo repository to create the query scope value Implements query.Rollbacker interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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