I'm working on a generic implementation of a paginator for DB queries with GORM
type Cursor struct {
Data []interface{}
Next int
}
type Paginator struct {
PageSize int
Model interface{}
}
The problem is, I don't know how to instantiate a new array to retrieve results from DB depending on the Paginator.Model type with this line
db.Model(paginator.Model).Limit(paginator.PageSize).Offset(page - 1).Find(&data)
How can I instantiate data to work with Find?