helpers.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package gorm
  2. import (
  3. "errors"
  4. "time"
  5. "unicode"
  6. )
  7. var (
  8. // ErrRecordNotFound record not found error
  9. ErrRecordNotFound = errors.New("record not found")
  10. // ErrInvalidSQL invalid SQL error, happens when you passed invalid SQL
  11. ErrInvalidSQL = errors.New("invalid SQL")
  12. // ErrInvalidTransaction invalid transaction when you are trying to `Commit` or `Rollback`
  13. ErrInvalidTransaction = errors.New("no valid transaction")
  14. // ErrUnaddressable unaddressable value
  15. ErrUnaddressable = errors.New("using unaddressable value")
  16. // ErrNotImplemented not implemented
  17. ErrNotImplemented = errors.New("not implemented")
  18. )
  19. // Model a basic GoLang struct which includes the following fields: ID, CreatedAt, UpdatedAt, DeletedAt
  20. // It may be embeded into your model or you may build your own model without it
  21. // type User struct {
  22. // gorm.Model
  23. // }
  24. type Model struct {
  25. ID uint `gorm:"primarykey"`
  26. CreatedAt time.Time
  27. UpdatedAt time.Time
  28. DeletedAt *time.Time `gorm:"index"`
  29. }
  30. func isChar(c rune) bool {
  31. return !unicode.IsLetter(c) && !unicode.IsNumber(c)
  32. }