mongo

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 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) (err 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
	// TODO: add TLS
	// 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 mongo 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) DriverName added in v0.2.2

func (f *Factory) DriverName() string

DriverName implements repository.Repository interface.

func (*Factory) New

New create new Mongo repository for the provided ModelStruct.

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.Repository.

func (*Repository) Begin

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

Begin implements query.Transactioner interface, Begin method.

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 implements query.Transactioner interface, Commit method.

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.Creator 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.ManyCreator 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 get the query scope value from the mongo database. Implements query.Getter 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 driver name for the mongo repository. Implements repository.Repository interface.

func (*Repository) Rollback

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

Rollback implements query.Transactioner interface, Rollback method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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