mgmadapter

package
v0.0.0-...-592bad0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyID

func EmptyID() kitty.ID

EmptyID returns empty instance of the id.

func ID

func ID(id interface{}) kitty.ID

IDD function get an id and returns IDD

Types

type DateFields

type DateFields struct {
	CreatedAt time.Time `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time `json:"updated_at" bson:"updated_at"`
}

DateFields struct contain `created_at` and `updated_at` fields that autofill on insert/update model.

func (*DateFields) Creating

func (f *DateFields) Creating() error

Creating hook used here to set `created_at` field value on inserting new model into database.

func (*DateFields) Saving

func (f *DateFields) Saving() error

Saving hook used here to set `updated_at` field value on create/update model.

type Entity

type Entity struct {
	IDField    `bson:",inline"`
	DateFields `bson:",inline"`
}

Entity struct contain model's default fields.

func (*Entity) Creating

func (model *Entity) Creating() error

Creating function call to it's inner fields defined hooks

func (*Entity) Saving

func (model *Entity) Saving() error

Saving function call to it's inner fields defined hooks

type IDField

type IDField struct {
	ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`
}

IDField struct contain model's ID field.

func (*IDField) GetID

func (f *IDField) GetID() interface{}

GetID method return model's id

func (*IDField) PrepareID

func (f *IDField) PrepareID(id interface{}) (objID interface{}, err error)

PrepareID method prepare id value to using it as id in filtering,... e.g convert hex-string id value to bson.ObjectId

func (*IDField) SetID

func (f *IDField) SetID(id interface{})

SetID set id value of model's id field.

type Repository

type Repository struct {
}

func (Repository) ReplaceErr

func (a Repository) ReplaceErr(err error, notfoundErr error) error

Jump to

Keyboard shortcuts

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