package models

import (
	"gorm.io/gorm"
	"time"
)

type User struct {
	ID            string `gorm:"size:36;not null; uniqueIndex; primary_key"`
	Addresses     string
	FirstName     string
	LastName      string
	Email         string
	Password      string
	RememberToken string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	DeletedAt     gorm.DeletedAt
}

func (u *User) FindByID(db *gorm.DB, userID string) (*User, error) {

	var user User

	err := db.Debug().Model(User{}).Where("id = ?", userID).
		First(&user).Error
	if err != nil {
		return nil, err
	}
	return &user, nil
}
