Skip to content

mongodb

import "budget-tracker-api-v2/internal/repository/mongodb"

Index

func NewCardRepository

func NewCardRepository(ctx context.Context, tracer trace.Tracer, c repository.CardCollectionInterface) (repository.CardRepoInterface, error)

NewCardRepository will return an CardRepoInterface for mongodb

func NewClient

func NewClient() (*mongo.Client, error)

NewClient will return a valid mongoDB connection

func NewTransactionRepository

func NewTransactionRepository(ctx context.Context, tracer trace.Tracer, c repository.TransactionCollectionInterface) (repository.TransactionRepoInterface, error)

NewTransactionRepository will return an TransactionRepoInterface for mongodb

func NewUserRepository

func NewUserRepository(ctx context.Context, tracer trace.Tracer, c repository.UserCollectionInterface) (repository.UserRepoInterface, error)

NewUserRepository will return an UserRepoInterface for mongodb

type CardCollectionConfig

CardCollectionConfig will implement mongodb collection functions

type CardCollectionConfig struct {
    Tracer          trace.Tracer
    MongoCollection *mongo.Collection
}

func (*CardCollectionConfig) CreateIndexes

func (c *CardCollectionConfig) CreateIndexes(ctx context.Context, indexes []string) error

CreateIndexes will create mongodb indexes

func (*CardCollectionConfig) DeleteOne

func (c *CardCollectionConfig) DeleteOne(ctx context.Context, id string) (int64, error)

DeleteOne will find a Card from collection

func (*CardCollectionConfig) FindOne

func (c *CardCollectionConfig) FindOne(ctx context.Context, id string) (*model.Card, error)

FindOne will find a Card from collection

func (*CardCollectionConfig) FindOneByFilter

func (c *CardCollectionConfig) FindOneByFilter(ctx context.Context, filter bson.M) (*model.Card, error)

FindOne will find a Card from collection

func (*CardCollectionConfig) InsertOne

func (c *CardCollectionConfig) InsertOne(ctx context.Context, document interface{}) (id string, err error)

InsertOne will insert a document into mongodb

type CardMockCollectionConfig

CardMockCollectionConfig will implement mongodb collection functions

type CardMockCollectionConfig struct {
    Error error
}

func (*CardMockCollectionConfig) CreateIndexes

func (c *CardMockCollectionConfig) CreateIndexes(ctx context.Context, indexes []string) error

CreateIndexes will create mongodb indexes

func (*CardMockCollectionConfig) DeleteOne

func (c *CardMockCollectionConfig) DeleteOne(ctx context.Context, id string) (int64, error)

DeleteOne will insert a document into mongodb

func (*CardMockCollectionConfig) FindOne

func (c *CardMockCollectionConfig) FindOne(ctx context.Context, id string) (*model.Card, error)

FindOne will insert a document into mongodb

func (*CardMockCollectionConfig) FindOneByFilter

func (c *CardMockCollectionConfig) FindOneByFilter(ctx context.Context, filter bson.M) (*model.Card, error)

FindOne will insert a document into mongodb

func (*CardMockCollectionConfig) InsertOne

func (c *CardMockCollectionConfig) InsertOne(ctx context.Context, document interface{}) (id string, err error)

InsertOne will insert a document into mongodb

type HealthCollectionConfig

HealthCollectionConfig will implement mongodb collection functions for healthchecks

type HealthCollectionConfig struct {
    Tracer          trace.Tracer
    MongoCollection *mongo.Collection
}

func (*HealthCollectionConfig) Ping

func (c *HealthCollectionConfig) Ping(ctx context.Context) (healthy bool, err error)

type HealthMockCollectionConfig

UserMockCollectionConfig will implement mongodb collection functions

type HealthMockCollectionConfig struct {
    Error error
}

func (*HealthMockCollectionConfig) Ping

func (c *HealthMockCollectionConfig) Ping(ctx context.Context) (bool, error)

CreateIndexes will create mongodb indexes

type MongoCardRepository

MongoCardRepository defines a Repository for Card model

type MongoCardRepository struct {
    Tracer          trace.Tracer
    MongoCollection repository.CardCollectionInterface
}

func (*MongoCardRepository) Delete

func (r *MongoCardRepository) Delete(ctx context.Context, empID string) (int64, error)

Delete will delete an card based on its ID

func (*MongoCardRepository) FindByFilter

func (r *MongoCardRepository) FindByFilter(ctx context.Context, filter bson.M) (*model.Card, error)

FindByFilter will fetch an card based on a certain filter

func (*MongoCardRepository) FindByID

func (r *MongoCardRepository) FindByID(ctx context.Context, empID string) (*model.Card, error)

FindByID will fetch an card based on its ID

func (*MongoCardRepository) Insert

func (r *MongoCardRepository) Insert(ctx context.Context, emp *model.Card) (*model.Card, error)

Insert will insert an card

type MongoHealthRepository

MongoHealthRepository defines a Repository for User model

type MongoHealthRepository struct {
    MongoCollection repository.HealthCollectionInterface
}

type MongoTransactionRepository

type MongoTransactionRepository struct {
    Tracer          trace.Tracer
    MongoCollection repository.TransactionCollectionInterface
}

func (*MongoTransactionRepository) Delete

func (r *MongoTransactionRepository) Delete(ctx context.Context, empID string) (int64, error)

Delete will delete an card based on its ID

func (*MongoTransactionRepository) FindByID

func (r *MongoTransactionRepository) FindByID(ctx context.Context, empID string) (*model.Transaction, error)

FindByID will fetch an card based on its ID

func (*MongoTransactionRepository) Insert

func (r *MongoTransactionRepository) Insert(ctx context.Context, transaction *model.Transaction) (*model.Transaction, error)

Insert will insert an card

type MongoUserRepository

MongoUserRepository defines a Repository for User model

type MongoUserRepository struct {
    MongoCollection repository.UserCollectionInterface
}

func (*MongoUserRepository) Delete

func (r *MongoUserRepository) Delete(ctx context.Context, empID string) (int64, error)

Delete will delete an user based on its ID

func (*MongoUserRepository) FindByID

func (r *MongoUserRepository) FindByID(ctx context.Context, empID string) (*model.User, error)

FindByID will fetch an user based on its ID

func (*MongoUserRepository) Insert

func (r *MongoUserRepository) Insert(ctx context.Context, emp *model.User) (*model.User, error)

Insert will insert an user

type TransactionCollectionConfig

TransactionCollectionConfig will implement mongodb collection functions

type TransactionCollectionConfig struct {
    Tracer          trace.Tracer
    MongoCollection *mongo.Collection
}

func (*TransactionCollectionConfig) CreateIndexes

func (c *TransactionCollectionConfig) CreateIndexes(ctx context.Context, indexes []string) error

CreateIndexes will create mongodb indexes

func (*TransactionCollectionConfig) DeleteOne

func (c *TransactionCollectionConfig) DeleteOne(ctx context.Context, id string) (int64, error)

DeleteOne will find a Transaction from collection

func (*TransactionCollectionConfig) FindOne

func (c *TransactionCollectionConfig) FindOne(ctx context.Context, id string) (*model.Transaction, error)

FindOne will find a Transaction from collection

func (*TransactionCollectionConfig) InsertOne

func (c *TransactionCollectionConfig) InsertOne(ctx context.Context, t *model.Transaction) (transaction *model.Transaction, err error)

InsertOne will insert a document into mongodb

type TransactionMockCollectionConfig

TransactionMockCollectionConfig will implement mongodb collection functions

type TransactionMockCollectionConfig struct {
    Error error
}

func (*TransactionMockCollectionConfig) CreateIndexes

func (c *TransactionMockCollectionConfig) CreateIndexes(ctx context.Context, indexes []string) error

CreateIndexes will create mongodb indexes

func (*TransactionMockCollectionConfig) DeleteOne

func (c *TransactionMockCollectionConfig) DeleteOne(ctx context.Context, id string) (int64, error)

DeleteOne will insert a document into mongodb

func (*TransactionMockCollectionConfig) FindOne

func (c *TransactionMockCollectionConfig) FindOne(ctx context.Context, id string) (*model.Transaction, error)

FindOne will find a document based on ID

func (*TransactionMockCollectionConfig) InsertOne

func (c *TransactionMockCollectionConfig) InsertOne(ctx context.Context, emp *model.Transaction) (transaction *model.Transaction, err error)

InsertOne will insert a document into mongodb

type UserCollectionConfig

UserCollectionConfig will implement mongodb collection functions

type UserCollectionConfig struct {
    Tracer          trace.Tracer
    MongoCollection *mongo.Collection
}

func (*UserCollectionConfig) CreateIndexes

func (c *UserCollectionConfig) CreateIndexes(ctx context.Context, indexes []string) error

CreateIndexes will create mongodb indexes

func (*UserCollectionConfig) DeleteOne

func (c *UserCollectionConfig) DeleteOne(ctx context.Context, id string) (int64, error)

DeleteOne will find a User from collection

func (*UserCollectionConfig) FindOne

func (c *UserCollectionConfig) FindOne(ctx context.Context, id string) (*model.User, error)

FindOne will find a User from collection

func (*UserCollectionConfig) FindOneBy

func (c *UserCollectionConfig) FindOneBy(ctx context.Context, login string) (*model.User, error)

FindOne will find a User from collection

func (*UserCollectionConfig) InsertOne

func (c *UserCollectionConfig) InsertOne(ctx context.Context, document interface{}) (id string, err error)

InsertOne will insert a document into mongodb

type UserCollectionInterface

UserCollectionInterface defines a mongodb collection API to be posteriorly mocked

type UserCollectionInterface interface {
    CreateIndexes(ctx context.Context, indexes []string) error
    InsertOne(ctx context.Context, document interface{}) (id string, err error)
    FindOne(ctx context.Context, id string) (*model.User, error)
    FindOneBy(ctx context.Context, xd string) (*model.User, error)
    DeleteOne(ctx context.Context, id string) (int64, error)
}

type UserMockCollectionConfig

UserMockCollectionConfig will implement mongodb collection functions

type UserMockCollectionConfig struct {
    Error error
}

func (*UserMockCollectionConfig) CreateIndexes

func (c *UserMockCollectionConfig) CreateIndexes(ctx context.Context, indexes []string) error

CreateIndexes will create mongodb indexes

func (*UserMockCollectionConfig) DeleteOne

func (c *UserMockCollectionConfig) DeleteOne(ctx context.Context, id string) (int64, error)

DeleteOne will insert a document into mongodb

func (*UserMockCollectionConfig) FindOne

func (c *UserMockCollectionConfig) FindOne(ctx context.Context, id string) (*model.User, error)

FindOne will find a document based on ID

func (*UserMockCollectionConfig) FindOneBy

func (c *UserMockCollectionConfig) FindOneBy(ctx context.Context, login string) (*model.User, error)

FindOneBy will find a document based on field

func (*UserMockCollectionConfig) InsertOne

func (c *UserMockCollectionConfig) InsertOne(ctx context.Context, document interface{}) (id string, err error)

InsertOne will insert a document into mongodb

Generated by gomarkdoc