mirror of
https://github.com/simon-ding/polaris.git
synced 2026-04-21 19:27:30 +08:00
feat: add create_time to db
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/storage"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -101,6 +102,20 @@ func (sc *StorageCreate) SetNillableDefault(b *bool) *StorageCreate {
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (sc *StorageCreate) SetCreateTime(t time.Time) *StorageCreate {
|
||||
sc.mutation.SetCreateTime(t)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
||||
func (sc *StorageCreate) SetNillableCreateTime(t *time.Time) *StorageCreate {
|
||||
if t != nil {
|
||||
sc.SetCreateTime(*t)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// Mutation returns the StorageMutation object of the builder.
|
||||
func (sc *StorageCreate) Mutation() *StorageMutation {
|
||||
return sc.mutation
|
||||
@@ -144,6 +159,10 @@ func (sc *StorageCreate) defaults() {
|
||||
v := storage.DefaultDefault
|
||||
sc.mutation.SetDefault(v)
|
||||
}
|
||||
if _, ok := sc.mutation.CreateTime(); !ok {
|
||||
v := storage.DefaultCreateTime()
|
||||
sc.mutation.SetCreateTime(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -219,6 +238,10 @@ func (sc *StorageCreate) createSpec() (*Storage, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(storage.FieldDefault, field.TypeBool, value)
|
||||
_node.Default = value
|
||||
}
|
||||
if value, ok := sc.mutation.CreateTime(); ok {
|
||||
_spec.SetField(storage.FieldCreateTime, field.TypeTime, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user