mirror of
https://github.com/simon-ding/polaris.git
synced 2026-04-22 03:37:30 +08:00
feat: add create_time to db
This commit is contained in:
@@ -4,6 +4,7 @@ package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
@@ -27,6 +28,8 @@ const (
|
||||
FieldDeleted = "deleted"
|
||||
// FieldDefault holds the string denoting the default field in the database.
|
||||
FieldDefault = "default"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// Table holds the table name of the storage in the database.
|
||||
Table = "storages"
|
||||
)
|
||||
@@ -41,6 +44,7 @@ var Columns = []string{
|
||||
FieldSettings,
|
||||
FieldDeleted,
|
||||
FieldDefault,
|
||||
FieldCreateTime,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -58,6 +62,8 @@ var (
|
||||
DefaultDeleted bool
|
||||
// DefaultDefault holds the default value on creation for the "default" field.
|
||||
DefaultDefault bool
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() time.Time
|
||||
)
|
||||
|
||||
// Implementation defines the type for the "implementation" enum field.
|
||||
@@ -126,3 +132,8 @@ func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByDefault(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefault, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user