I am using SQL boiler and GOlang
"github.com/volatiletech/sqlboiler/v4/queries"
"github.com/volatiletech/sqlboiler/v4/queries/qm"
I want to set limit, offset and orderby in different columns
my code is
queryMods := []qm.QueryMod{
qm.OrderBy("hive_id"),
qm.Limit(10),
qm.Offset(0),
qm.Load(dbmodels.HiveUserDemographicRels.Answer),
qm.Load(dbmodels.HiveUserDemographicRels.Question),
qm.Load(dbmodels.HiveUserDemographicRels.Hive),
}
where := fmt.Sprintf(`hive on hive_user_demographic.hive_id=hive.hive_id and hive.deleted_at is null `)
queryMods = append(queryMods, qm.InnerJoin(where))
demographic, err := dbmodels.HiveUserDemographics(queryMods...).All(ctx, m.db)
using this code the limit and offset are based on the table HiveUserDemographic
But I want to set limit and offset in "Hive" table (dbmodels.HiveUserDemographicRels.Hive) like the mysql
SELECT hive_user_demographic.*
FROM (
SELECT *
FROM hive
where deleted_at is null
order by hive_id asc
LIMIT 10
OFFSET 0
) hive_data
JOIN hive_user_demographic on hive_data.hive_id=hive_user_demographic.hive_id
I tried this
queryMods := []qm.QueryMod{
qm.Load(dbmodels.HiveUserDemographicRels.Answer),
qm.Load(dbmodels.HiveUserDemographicRels.Question),
qm.Load(dbmodels.HiveUserDemographicRels.Hive, qm.Limit(1), qm.Offset(0)),
}
but not working
it getting panic error
[{Answer []} {Question []} {Hive [{1} {1}]} {hive on hive_user_demographic.hive_id=hive.hive_id and hive.deleted_at is null []} {hive.hive_id asc} {hive_user_demographic
}]
&{0x2096ca0 { []} [Answer Question Hive] map[Hive:[{1} {1}]] false map[] [] [] false [hive_user_demographic
] [{0 hive on hive_user_demographic.hive_id=hive.hive_id and hive.deleted_at is null []}] [] [] [{hive.hive_id asc []}] [] 0 0 }
hive_user_demographic have hive_id (eg 1,2..) with 10 row in each.. Hive table have hive_id (eg 1,2..) one each row. so I want to set limit and offset in hive table.
How can I set