//find all wallet history - Model Function
func FindAllHistory(condition interface{}) (WalletTransactionModel, error) {
db := common.GetDB()
var model WalletTransactionModel
err := db.Where(condition).Find(&model).Error
return model, err
}
//find all wallet history - Model Function
func FindAllHistory(condition interface{}) (WalletTransactionModel, error) {
db := common.GetDB()
var model WalletTransactionModel
err := db.Where(condition).Find(&model).Error
return model, err
}
Welcome to Go Forum .
And your question is?
Please note that:
WalletTransactionModel
without its struct descriptions.common
is which database package?This is a Function in my Model file that is suppose to collect all records based on condition, so example is that I queries and it returns a single object, but My terminal indicates atleast 5 rows where affected. So my challenge is that I seem not to Know how to send array of obects to the calling function for display. So the problem is that it fetches more than one record but return only one
type WalletTransactionModel struct {
ID int gorm:"primary_key;AUTO_INCREMENT"
Category string gorm:"not null"
Sender string gorm:"not null"
Receiver string gorm:"not null"
Description string gorm:"not null"
SessionID string gorm:"-"
PIN string gorm:"-"
OriginatingTransaction int
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
}
This is my
We need to know more about FindAllHistory(...)
, does it having a documentations (those comments on top of this functions?
A word of warning: since this is related to financial data (either real money or concurrency), please be careful and take your time filtering out sensitive information.
You should pass an array pointer to the Find method, not a single object.
var model WalletTransactionModel
datas := []WalletTransactionModel{}
err := db.Where(condition).Find(&datas).Error
Thanks @kync. This Executes But I still get One instance of my the Object instead of two instance returned as indicated in my terminal
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.