Skip to content

Commit

Permalink
update: DB NFT query change - Select to QueryRow
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaghettiOverload committed Sep 20, 2023
1 parent ee6de23 commit 89ca9df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 16 additions & 2 deletions database/nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,23 @@ func (tx *DbTx) UpdateNFTHistory(txHash string, tokenID uint64, denomID, from, t

func (db *Db) GetNftFromDB(nftID, denomID string) (dbtypes.NftFromDB, error) {
var nft dbtypes.NftFromDB
err := db.Sqlx.Select(&nft, `SELECT * FROM nft_nft WHERE id = $1 AND denom_id = $2`, nftID, denomID)
err := db.Sqlx.QueryRow(`SELECT * FROM nft_nft WHERE id = $1 AND denom_id = $2`, nftID, denomID).Scan(
&nft.TransactionHash,
&nft.ID,
&nft.DenomID,
&nft.Name,
&nft.URI,
&nft.DataJSON,
&nft.DataText,
&nft.Owner,
&nft.Sender,
&nft.ContractAddressSigner,
&nft.Burned,
&nft.UniqID,
&nft.PartionID,
)
if err != nil {
return nft, err
return dbtypes.NftFromDB{}, err
}
return nft, nil
}
3 changes: 2 additions & 1 deletion database/types/nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ type NftFromDB struct {
Sender string `json:"sender"`
ContractAddressSigner string `json:"contract_address_signer"`
Burned bool `json:"burned"`
UniqID sql.NullInt64 `json:"uniq_id"`
UniqID string `json:"uniq_id"`
PartionID sql.NullInt64 `json:"partition_id"`
}

0 comments on commit 89ca9df

Please sign in to comment.