2020-01-30 10:14:48 +03:00
|
|
|
package gorm
|
|
|
|
|
2020-01-31 01:35:25 +03:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
2020-02-16 08:45:27 +03:00
|
|
|
"unicode"
|
2020-01-31 01:35:25 +03:00
|
|
|
)
|
2020-01-30 10:14:48 +03:00
|
|
|
|
|
|
|
var (
|
|
|
|
// ErrRecordNotFound record not found error
|
|
|
|
ErrRecordNotFound = errors.New("record not found")
|
|
|
|
// ErrInvalidSQL invalid SQL error, happens when you passed invalid SQL
|
|
|
|
ErrInvalidSQL = errors.New("invalid SQL")
|
|
|
|
// ErrInvalidTransaction invalid transaction when you are trying to `Commit` or `Rollback`
|
|
|
|
ErrInvalidTransaction = errors.New("no valid transaction")
|
|
|
|
// ErrUnaddressable unaddressable value
|
|
|
|
ErrUnaddressable = errors.New("using unaddressable value")
|
|
|
|
)
|
|
|
|
|
2020-01-31 01:35:25 +03:00
|
|
|
// Model a basic GoLang struct which includes the following fields: ID, CreatedAt, UpdatedAt, DeletedAt
|
|
|
|
// It may be embeded into your model or you may build your own model without it
|
|
|
|
// type User struct {
|
|
|
|
// gorm.Model
|
|
|
|
// }
|
|
|
|
type Model struct {
|
2020-02-01 15:18:25 +03:00
|
|
|
ID uint `gorm:"primarykey"`
|
2020-01-31 01:35:25 +03:00
|
|
|
CreatedAt time.Time
|
|
|
|
UpdatedAt time.Time
|
|
|
|
DeletedAt *time.Time `gorm:"index"`
|
2020-01-30 10:14:48 +03:00
|
|
|
}
|
2020-02-16 08:45:27 +03:00
|
|
|
|
|
|
|
func isChar(c rune) bool {
|
|
|
|
return !unicode.IsLetter(c) && !unicode.IsNumber(c)
|
|
|
|
}
|