zkt24/z2/backend/ent/schema/transactions.go

33 lines
682 B
Go
Raw Permalink Normal View History

2024-04-25 11:51:47 +00:00
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Transactions holds the schema definition for the Transactions entity.
type Transactions struct {
ent.Schema
}
// Fields of the Transactions.
func (Transactions) Fields() []ent.Field {
return []ent.Field{
field.Int("type"),
field.Int("timestamp"),
field.String("comment"),
field.Bytes("content"),
field.String("hash").Unique(),
field.String("signature").Unique(),
}
}
// Edges of the Transactions.
func (Transactions) Edges() []ent.Edge {
return []ent.Edge{
edge.From("Signer", Key.Type).Ref("Signed"),
edge.From("Block", Blocks.Type).Ref("MinedTxs"),
}
}