database

package
v0.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	Name      string     `json:"name" bson:"name"`
	Deleted   bool       `json:"-"    bson:"deleted"`
	DeletedAt *time.Time `json:"-"    bson:"deletedAt"`
}

func (Author) Validate

func (Author) Validate(ctx context.Context, arg *mgs.HookArg[Author]) error

type AuthorDoc

type AuthorDoc = mgs.Document[Author, *mgs.DefaultSchema]

type AuthorModel

type AuthorModel = mgs.Model[Author, *mgs.DefaultSchema]

func NewAuthorModel

func NewAuthorModel(coll *mongo.Collection) *AuthorModel

type Book

type Book struct {
	Title string `json:"title"    bson:"title"`
	// ObjectID or Author Object
	Author    interface{}   `json:"author"   bson:"author"`
	Reviews   []interface{} `json:"chapters" bson:"chapters"`
	Deleted   bool          `json:"-"        bson:"deleted"`
	DeletedAt *time.Time    `json:"-"        bson:"deletedAt"`
}

func (Book) AfterCreate

func (book Book) AfterCreate(ctx context.Context, arg *mgs.HookArg[Book]) error

func (Book) AfterDelete

func (book Book) AfterDelete(ctx context.Context, arg *mgs.HookArg[Book]) error

func (Book) AfterFind

func (book Book) AfterFind(ctx context.Context, arg *mgs.HookArg[Book]) error

func (Book) AfterUpdate

func (book Book) AfterUpdate(ctx context.Context, arg *mgs.HookArg[Book]) error

func (Book) AfterValidate

func (Book) AfterValidate(ctx context.Context, arg *mgs.HookArg[Book]) error

func (Book) BeforeCreate

func (Book) BeforeCreate(ctx context.Context, arg *mgs.HookArg[Book]) error

func (Book) BeforeDelete

func (book Book) BeforeDelete(ctx context.Context, arg *mgs.HookArg[Book]) error

func (Book) BeforeFind

func (book Book) BeforeFind(ctx context.Context, arg *mgs.HookArg[Book]) error

func (Book) BeforeUpdate

func (book Book) BeforeUpdate(ctx context.Context, arg *mgs.HookArg[Book]) error

func (Book) BeforeValidate

func (Book) BeforeValidate(ctx context.Context, arg *mgs.HookArg[Book]) error

func (Book) Validate

func (Book) Validate(ctx context.Context, arg *mgs.HookArg[Book]) error

type BookDoc

type BookDoc = mgs.Document[Book, *mgs.DefaultSchema]

type BookModel

type BookModel = mgs.Model[Book, *mgs.DefaultSchema]

func NewBookModel

func NewBookModel(coll *mongo.Collection) *BookModel

type Review

type Review struct {
	// ObjectID or Book object
	Book    interface{} `bson:"book"    json:"book"    validate:"required"`
	Comment string      `bson:"comment" json:"comment" validate:"required"`
	Rating  int         `bson:"rating"  json:"rating"  validate:"required"`
}

func (Review) Validate

func (Review) Validate(ctx context.Context, arg *mgs.HookArg[Review]) error

type ReviewDoc

type ReviewDoc = mgs.Document[Review, *mgs.DefaultSchema]

type ReviewModel

type ReviewModel = mgs.Model[Review, *mgs.DefaultSchema]

func NewReviewModel

func NewReviewModel(coll *mongo.Collection) *ReviewModel

Jump to

Keyboard shortcuts

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