package dao

import "gorm.io/gorm"

type Transaction struct {
	gorm.Model
	TxId    string `gorm:"column:tx_id" json:"tx_id"`
	Network string `gorm:"column:network" json:"network"`
	Coin    string `gorm:"column:coin" json:"coin"`
	From    string `gorm:"column:from" json:"from"`
	To      string `gorm:"column:to" json:"to"`
	Amount  string `gorm:"column:amount" json:"amount"`
	TxHash  string `gorm:"type:varchar(200);column:tx_hash;uniqueIndex" json:"tx_hash"`
}

func (t *Transaction) TableName() string {
	return "wallet_server_transaction"
}

func (dao *Dao) CreateTransaction(data *Transaction) error {
	return dao.db.Create(&data).Error
}
