Skip to content
Snippets Groups Projects
Commit 85998571 authored by meskio's avatar meskio :tent:
Browse files

Make num and code the primary keys

parent d61a9bdf
Branches
Tags
No related merge requests found
......@@ -17,16 +17,19 @@ const (
)
type Member struct {
gorm.Model `json:"-"`
Num int `json:"num" gorm:"unique;index"`
Login string `json:"login" gorm:"unique;index"`
Name string `json:"name"`
Email string `json:"email"`
Phone string `json:"phone"`
Balance int `json:"balance"`
Role string `json:"role"`
PassHash []byte `json:"-"`
Salt []byte `json:"-"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
Num int `json:"num" gorm:"primaryKey"`
Login string `json:"login" gorm:"unique;index"`
Name string `json:"name"`
Email string `json:"email"`
Phone string `json:"phone"`
Balance int `json:"balance"`
Role string `json:"role"`
PassHash []byte `json:"-"`
Salt []byte `json:"-"`
}
type PasswordReset struct {
......
......@@ -2,16 +2,20 @@ package db
import (
"errors"
"time"
"gorm.io/gorm"
)
type Product struct {
gorm.Model `json:"-"`
Code int `json:"code" gorm:"unique;index"`
Name string `json:"name" gorm:"unique;index"`
Price int `json:"price"`
Stock int `json:"stock"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
Code int `json:"code" gorm:"primaryKey"`
Name string `json:"name" gorm:"unique;index"`
Price int `json:"price"`
Stock int `json:"stock"`
}
func (d *DB) AddProduct(product *Product) error {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment