MCPcopy Create free account
hub / github.com/go-pg/pg / ForEach

Method ForEach

orm/query.go:978–981  ·  view source on GitHub ↗

ForEach calls the function for each row returned by the query without loading all rows into the memory. Function can accept a struct, a pointer to a struct, an orm.Model, or values for the columns in a row. Function must return an error.

(fn interface{})

Source from the content-addressed store, hash-verified

976// Function can accept a struct, a pointer to a struct, an orm.Model,
977// or values for the columns in a row. Function must return an error.
978func (q *Query) ForEach(fn interface{}) error {
979 m := newFuncModel(fn)
980 return q.Select(m)
981}
982
983func (q *Query) forEachHasOneJoin(fn func(*join) error) error {
984 if q.tableModel == nil {

Callers 3

BenchmarkForEachRealFunction · 0.80
ExampleDB_Model_forEachFunction · 0.80
db_test.goFile · 0.80

Calls 2

SelectMethod · 0.95
newFuncModelFunction · 0.85

Tested by 2

BenchmarkForEachRealFunction · 0.64
ExampleDB_Model_forEachFunction · 0.64