mongo

package
v0.0.0-...-d8b21ba Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollectionCategories = "categories"
	CollectionRecords    = "records"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CategoryService

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

func NewCategoryService

func NewCategoryService(categories categoryCollection, records distinctFinder) *CategoryService

func (*CategoryService) Add

func (c *CategoryService) Add(ctx context.Context, category *api.Category) error

func (*CategoryService) All

func (c *CategoryService) All(ctx context.Context) ([]api.Category, error)

func (*CategoryService) Find

func (c *CategoryService) Find(ctx context.Context, id string) (*api.Category, error)

func (*CategoryService) FindByPatient

func (c *CategoryService) FindByPatient(ctx context.Context, id string) ([]api.Category, error)

func (*CategoryService) Update

func (c *CategoryService) Update(ctx context.Context, category *api.Category) error

type Client

type Client struct {
	*mongo.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config datastore.DatabaseConfig) *Client

func (*Client) Categories

func (c *Client) Categories() *mongo.Collection

func (*Client) Check

func (c *Client) Check(ctx context.Context) (string, error)

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) error

func (*Client) CreateIndexes

func (c *Client) CreateIndexes(ctx context.Context) error

func (*Client) Database

func (c *Client) Database() *mongo.Database

func (*Client) Disconnect

func (c *Client) Disconnect(ctx context.Context) error

func (*Client) Records

func (c *Client) Records() *mongo.Collection

type Collection

type Collection struct {
	*mongo.Collection
}

func NewCollection

func NewCollection(collection *mongo.Collection) *Collection

func (*Collection) DeleteOne

func (c *Collection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*Collection) Distinct

func (c *Collection) Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)

func (*Collection) Find

func (c *Collection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (datastore.Cursor, error)

func (*Collection) FindOne

func (c *Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) datastore.Decodable

func (*Collection) FindOneAndUpdate

func (c *Collection) FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) datastore.Decodable

func (*Collection) InsertOne

func (c *Collection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

type Counter

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

func NewCounter

func NewCounter(client *Client) *Counter

func (*Counter) Count

func (c *Counter) Count(ctx context.Context, resource string) (int64, error)

type RecordService

type RecordService struct {
	RecordServiceConfig
}

func NewRecordService

func NewRecordService(config RecordServiceConfig) *RecordService

func (*RecordService) All

func (r *RecordService) All(ctx context.Context) ([]api.Record, error)

func (*RecordService) Create

func (r *RecordService) Create(ctx context.Context, data api.CreateRecord, images []storage.Image, pdfData io.Reader) (created *api.Record, resErr error)

func (*RecordService) Delete

func (r *RecordService) Delete(ctx context.Context, id string) error

func (*RecordService) Find

func (r *RecordService) Find(ctx context.Context, id string) (*api.Record, error)

func (*RecordService) Query

func (r *RecordService) Query(ctx context.Context, recordQuery datastore.RecordQuery, queryOptions ...*datastore.QueryOptions) ([]api.Record, error)

func (*RecordService) Update

func (r *RecordService) Update(ctx context.Context, id string, record api.Record, updateOptions ...datastore.UpdateOption) (*api.Record, error)

func (*RecordService) UpdatePages

func (r *RecordService) UpdatePages(ctx context.Context, id string, updates []api.PageUpdate) (*api.Record, error)

UpdatePages updates the pages of a document without modifying the pages themselves. Useful for deleting multiple pages

type RecordServiceConfig

type RecordServiceConfig struct {
	Records recordCollection
	Events  event.Sender[*api.Record]
	Images  storage.ResourceWriter
	Pdfs    storage.ResourceWriter
}

type TagService

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

func NewTagService

func NewTagService(records distinctFinder) *TagService

func (*TagService) All

func (t *TagService) All(ctx context.Context) ([]string, error)

func (*TagService) ByPatient

func (t *TagService) ByPatient(ctx context.Context, id string) ([]string, error)

Jump to

Keyboard shortcuts

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