fix: some api bug
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -17,7 +19,7 @@ type Wallet struct {
|
||||
// Fields of the Wallet.
|
||||
func (Wallet) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int64("user_id").Immutable().Unique(),
|
||||
field.Int64("id").StorageKey("user_id").Immutable().Unique(),
|
||||
field.Other("balance", decimal.Decimal{}).
|
||||
Default(defalutBalance).
|
||||
SchemaType(map[string]string{
|
||||
@@ -29,7 +31,7 @@ func (Wallet) Fields() []ent.Field {
|
||||
dialect.Postgres: "decimal(12,2)",
|
||||
}),
|
||||
field.Int("version").Default(1),
|
||||
field.Time("updated_at"),
|
||||
field.Time("updated_at").Default(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"juwan-backend/pkg/types"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
@@ -26,10 +29,14 @@ func (WalletTransactions) Fields() []ent.Field {
|
||||
SchemaType(map[string]string{
|
||||
dialect.Postgres: "decimal(12,2)",
|
||||
}).Unique().Immutable(),
|
||||
field.Strings("description"),
|
||||
field.Other("description", types.TextArray{}).SchemaType(map[string]string{
|
||||
dialect.Postgres: "text[]",
|
||||
}).Optional(),
|
||||
field.Int64("order_id").Immutable().Unique(),
|
||||
field.Time("created_at"),
|
||||
field.String("search_text"),
|
||||
field.String("search_text").Optional().Immutable().Annotations(entsql.Annotation{
|
||||
Skip: true,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user