mongo

package
v0.0.0-...-43028c6 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureMongoClient

func ConfigureMongoClient(app *feathers.App, config map[string]interface{}) error

ConfigureMongoClient configures a mongo client for usage whith the mongoservice

client is saved to `mongoClient` key in app config

func MapDecodeMongo

func MapDecodeMongo() mapstructure.DecodeHookFunc

func MongoKeys

func MongoKeys(fields ...string) feathers.Hook

func NormalizeObjectId

func NormalizeObjectId(id interface{}) primitive.ObjectID

func ObjectIDEquals

func ObjectIDEquals(id interface{}, id2 interface{}) bool

Types

type Document

type Document struct {
	ID primitive.ObjectID `bson:"_id" mapstructure:"_id,omitempty" json:"_id" ts_type:"string"`
}

func NewDocument

func NewDocument() *Document

func (*Document) GenerateID

func (d *Document) GenerateID()

func (*Document) IDIsZero

func (d *Document) IDIsZero() bool

type IdDocument

type IdDocument interface {
	GenerateID()
	IDIsZero() bool
}

type Service

type Service struct {
	*feathers.BaseService
	*feathers.ModelService

	CollectionName string
	// contains filtered or unexported fields
}

Service for mongodb which offers model validation. Use `NewService` for new instance. (another service is supposed to extend from this)

func NewService

func NewService(collection string, model feathers.ModelFactory, app *feathers.App) *Service

NewService creates a new mongo service struct

func (*Service) Collection

func (f *Service) Collection() (*mongo.Collection, bool)

func (*Service) Create

func (f *Service) Create(ctx context.Context, data map[string]interface{}, params feathers.Params) (interface{}, error)

func (*Service) Find

func (f *Service) Find(ctx context.Context, params feathers.Params) (interface{}, error)

func (*Service) Get

func (f *Service) Get(ctx context.Context, id string, params feathers.Params) (interface{}, error)

func (*Service) Patch

func (f *Service) Patch(ctx context.Context, id string, data map[string]interface{}, params feathers.Params) (interface{}, error)

func (*Service) Remove

func (f *Service) Remove(ctx context.Context, id string, params feathers.Params) (interface{}, error)

func (*Service) Update

func (f *Service) Update(ctx context.Context, id string, data map[string]interface{}, params feathers.Params) (interface{}, error)

type TimestampDoc

type TimestampDoc struct {
	CreatedAt primitive.DateTime `bson:"createdAt" mapstructure:"createdAt" json:"createdAt"`
	UpdatedAt primitive.DateTime `bson:"updatedAt" mapstructure:"updatedAt" json:"updatedAt"`
}

func (*TimestampDoc) SetCreatedAt

func (td *TimestampDoc) SetCreatedAt()

func (*TimestampDoc) SetUpdatedAt

func (td *TimestampDoc) SetUpdatedAt()

type Timestampable

type Timestampable interface {
	SetCreatedAt()
	SetUpdatedAt()
}

Jump to

Keyboard shortcuts

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