Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Date ¶ added in v0.1.0
Example ¶
dbName, dsn, db := Setup() dsn = strings.ReplaceAll(dsn, "dbname="+dbName, "dbname=postgres") defer Teardown(dbName, dsn, db) // ^^^ Setup for the PG DB. This can be ignored type DateExample struct { ID uint `gorm:"primarykey"` OnlyDate dtegorm.Date } onlyDate, err := dtegorm.NewDate("2006-01-02") if err != nil { return } example := DateExample{OnlyDate: onlyDate} createResult := db.Create(&example) if createResult.Error != nil { return } var exampleResult DateExample getResult := db.First(&exampleResult, example.ID) if getResult.Error != nil { return } fmt.Println(exampleResult.OnlyDate.String())
Output: 2006-01-02
func (Date) GormDBDataType ¶ added in v0.1.0
GormDBDataType returns gorm DB data type based on the current using database.
func (Date) GormDataType ¶ added in v0.1.0
GormDataType returns gorm common data type. This type is used for the field's column type.
type Time ¶
Example ¶
dbName, dsn, db := Setup() dsn = strings.ReplaceAll(dsn, "dbname="+dbName, "dbname=postgres") defer Teardown(dbName, dsn, db) // ^^^ Setup for the PG DB. This can be ignored type TimeExample struct { ID uint `gorm:"primarykey"` OnlyTime dtegorm.Time } onlyTime, err := dtegorm.NewTime("10:04:05-05:00") if err != nil { return } example := TimeExample{OnlyTime: onlyTime} createResult := db.Create(&example) if createResult.Error != nil { return } var exampleResult TimeExample getResult := db.First(&exampleResult, example.ID) if getResult.Error != nil { return } fmt.Println(exampleResult.OnlyTime.String())
Output: 15:04:05Z
func (Time) GormDBDataType ¶
GormDBDataType returns gorm DB data type based on the current using database.
func (Time) GormDataType ¶
GormDataType returns gorm common data type. This type is used for the field's column type.
Click to show internal directories.
Click to hide internal directories.