Get data count from psql

Hi,

I am trying to get the id and count of params related to that from psql in golang. but I stuck as i am getting the error like *"missing destination name action_count in []store.stat"

my function is ->

func (orgStore) GetBotStat(db *sqlx.DB, IDS uint64) (stat []Stat, err error) {
q := SELECT id , count(action) AS action_count from snapshot WHERE id IN ( select id from bot where ids = $1) GROUP BY id ORDER BY id
err = db.Select(&stat, q, IDS)
return
}

type Stat struct{
ID string json:"bot_id" db:"bot_id"
ActionCount uint64 json:"action_count" db:action_count

}

Could anyone help me in this.
I am bit confused how to get the count and other data from the same query in golang .

Thanks in Advance

Change it from:

ActionCount uint64 `json:"action_count" db:action_count`

to

ActionCount uint64 `json:"action_count" db:"action_count"`

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.