model

package
v0.0.0-...-e970dd6 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllGender = []Gender{
	GenderMale,
	GenderFemale,
}

Functions

This section is empty.

Types

type Gender

type Gender string
const (
	GenderMale   Gender = "MALE"
	GenderFemale Gender = "FEMALE"
)

func (Gender) IsValid

func (e Gender) IsValid() bool

func (Gender) MarshalGQL

func (e Gender) MarshalGQL(w io.Writer)

func (Gender) String

func (e Gender) String() string

func (*Gender) UnmarshalGQL

func (e *Gender) UnmarshalGQL(v interface{}) error

type NewTodo

type NewTodo struct {
	Text   string `json:"text"`
	UserID int    `json:"userId"`
}

type NewUser

type NewUser struct {
	Name   string `json:"name"`
	Gender Gender `json:"gender"`
}

type Todo

type Todo struct {
	bun.BaseModel `bun:"table: todos,alias:t"`
	ID            int       `bun:",pk,autoincrement" json:"id"`
	Text          string    `bun:"text,notnull" json:"text"`
	Done          bool      `bun:"done,notnull,default: '0'" json:"done"`
	UserID        int       `bun:"user_id,notnull" json:"user"`
	User          *User     `bun:"rel:belongs-to,join:user_id=id"`
	CreatedAt     time.Time `bun:"created_at,notnull" json:"-"`
	ModifiedAt    time.Time `bun:"modified_at,notnull" json:"-"`
}

Todo is the ORM model to save todos in the database and used when returning data for queries

func (*Todo) BeforeAppendModel

func (t *Todo) BeforeAppendModel(ctx context.Context, query schema.Query) error

func (*Todo) String

func (t *Todo) String() string

type User

type User struct {
	bun.BaseModel `bun:"table: users,alias:u"`
	ID            int       `bun:",pk,autoincrement" json:"id"`
	Name          string    `bun:"name,notnull" json:"name"`
	Gender        string    `bun:"gender,notnull" json:"gender"`
	CreatedAt     time.Time `bun:"created_at,notnull" json:"-"`
	ModifiedAt    time.Time `bun:"modified_at,notnull" json:"-"`
}

User is the ORM model to save user in the database and return the data back to consumers

func (*User) BeforeAppendModel

func (u *User) BeforeAppendModel(ctx context.Context, query schema.Query) error

func (*User) String

func (u *User) String() string

Jump to

Keyboard shortcuts

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