repository

package module
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 12 Imported by: 0

README

MongoDB Embed

Description

To make it easy for you to get started with GitLab, here's a list of recommended next steps.

Already a pro? Just edit this README.md and make it your own. Want to make it easy? Use the template at the bottom!

Add your files

cd existing_repo
git remote add origin https://gitlab.com/pedroalvesk/mongodb-embed.git
git branch -M main
git push -uf origin main

Integrate with your tools

Collaborate with your team

Test and Deploy

Use the built-in continuous integration in GitLab.


Editing this README

MongoDB Embed

Description

Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.

Installation

go get TBA

Usage

Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.

Roadmap

  • Generic Repository
  • Embedded structures

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func NewConfig

func NewConfig(uri string, dbName string, certificatePath string) *config

func NewConfigWithClient

func NewConfigWithClient(client *mongo.Client, database *mongo.Database) *config

Types

type Filter

type Filter struct {
	Key   string
	Value interface{}
}

type IDType

type IDType uint
const (
	String IDType = iota
	ObjectID
)

type Object

type Object interface {
	GetID() string
	SetID(id string)
}

type Repository

type Repository interface {
	Create(ctx context.Context, object StorableObject) error
	Update(ctx context.Context, objectID string, object StorableObject) error
	GetBy(ctx context.Context, object StorableObject, filters ...Filter) error
	GetByID(ctx context.Context, objectID string, object StorableObject) error
	Fetch(ctx context.Context, object StorableObject, out interface{}, filters ...Filter) error

	WithTransaction(ctx context.Context, fn func(sc context.Context) error) error
	Aggregate(ctx context.Context, object StorableObject, query string, out interface{}) error
	Count(ctx context.Context, object StorableObject, filter interface{}) (int64, error)

	Preload(ctx context.Context, object Object) error
}

func NewRepository

func NewRepository(cfg *config) (Repository, error)

type StorableObject added in v1.0.12

type StorableObject interface {
	Object
	GetCollection() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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