gorm

package
v0.0.0-...-8cf2643 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

@alchemy replace package dao

@alchemy replace package dao

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetIfPresent

func SetIfPresent(target interface{}, fieldName string, value interface{}) error

SetIfPresent sets a field of a struct if the provided value is not nil.

Types

type IUserDao

type IUserDao interface {
	List() ([]User, error)
	// @alchemy block {{- if .Login }}
	Get(string) (*User, error)
	GetByEmail(string) (*User, error)
	// @alchemy block {{- end }}
	// @alchemy block {{- if .Register }}
	Create(UserCreatePayload) (*User, error)
	// @alchemy block {{- end }}
	Update(string, UserUpdatePayload) (*User, error)
	Delete(string) error
}

func NewUserDao

func NewUserDao(client *gorm.DB) IUserDao

type User

type User struct {
	Id        string  `json:"id" gorm:"column:id;primaryKey;type:uuid;default:gen_random_uuid()"`
	FirstName *string `json:"firstName" gorm:"column:first_name"`
	LastName  *string `json:"lastName" gorm:"column:last_name"`
	Email     string  `json:"email" gorm:"email;unique"`
	Password  string  `json:"-" gorm:"password"`
}

type UserCreatePayload

type UserCreatePayload struct {
	FirstName *string `json:"firstName,omitempty"`
	LastName  *string `json:"lastName,omitempty"`
	Email     string  `json:"email,omitempty"`
	Password  string  `json:"password,omitempty"`
}

type UserDao

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

func (*UserDao) Create

func (u *UserDao) Create(payload UserCreatePayload) (*User, error)

func (*UserDao) Delete

func (u *UserDao) Delete(id string) error

func (*UserDao) Get

func (u *UserDao) Get(id string) (user *User, err error)

func (*UserDao) GetByEmail

func (u *UserDao) GetByEmail(email string) (user *User, err error)

@alchemy block {{- if .Login }}

func (*UserDao) List

func (u *UserDao) List() (users []User, err error)

func (*UserDao) Update

func (u *UserDao) Update(id string, payload UserUpdatePayload) (*User, error)

type UserUpdatePayload

type UserUpdatePayload struct {
	FirstName *string `json:"firstName,omitempty"`
	LastName  *string `json:"lastName,omitempty"`
	Email     *string `json:"email,omitempty"`
	Password  *string `json:"password,omitempty"`
}

Jump to

Keyboard shortcuts

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