From 9232f6d2abd2fe75578b5a56c1e08f5665e4c096 Mon Sep 17 00:00:00 2001 From: arashackdev Date: Mon, 1 Dec 2025 03:05:46 +0100 Subject: [PATCH 1/3] feat: add chunk by query methods (#714) --- contracts/database/orm/orm.go | 8 ++ database/gorm/query.go | 161 +++++++++++++++++++++++++++++ errors/list.go | 1 + mocks/database/orm/Query.go | 189 ++++++++++++++++++++++++++++++++++ 4 files changed, 359 insertions(+) diff --git a/contracts/database/orm/orm.go b/contracts/database/orm/orm.go index caece7feb..f95b18316 100644 --- a/contracts/database/orm/orm.go +++ b/contracts/database/orm/orm.go @@ -43,6 +43,12 @@ type Query interface { Begin() (Query, error) // BeginTransaction begins a new transaction BeginTransaction() (Query, error) + // Chunk processes a given number of records in batches. + Chunk(count int, callback func([]any) error) error + // Chunk the results of a query by comparing numeric IDs. + ChunkByID(count int, callback func([]any) error) error + // ChunkByIDDesc processes a given number of records in batches, ordered by ID in descending order. + ChunkByIDDesc(count int, callback func([]any) error) error // Commit commits the changes in a transaction. Commit() error // Count retrieve the "count" result of the query. @@ -120,6 +126,8 @@ type Query interface { OrderByDesc(column string) Query // OrderByRaw specifies the order should be raw. OrderByRaw(raw string) Query + // OrderedChunkByID processes a given number of records in batches, ordered by ID. + OrderedChunkByID(count int, callback func([]any) error, descending bool) error // OrWhere add an "or where" clause to the query. OrWhere(query any, args ...any) Query // OrWhereBetween adds an "or where column between x and y" clause to the query. diff --git a/database/gorm/query.go b/database/gorm/query.go index fbd61ba3f..d61df7a26 100644 --- a/database/gorm/query.go +++ b/database/gorm/query.go @@ -189,6 +189,167 @@ func (r *Query) Cursor() chan contractsdb.Row { return cursorChan } +func (r *Query) Chunk(count int, callback func([]any) error) error { + if count <= 0 { + return errors.OrmQueryChunkZeroOrLess + } + + var remaining *int + if r.conditions.limit != nil { + limit := *r.conditions.limit + remaining = &limit + } + + query := r.addGlobalScopes().buildConditions() + + destType := reflect.TypeOf(r.conditions.model) + sliceType := reflect.SliceOf(reflect.PointerTo(destType)) + offset := 0 + + for remaining == nil || *remaining > 0 { + chunkLimit := count + if remaining != nil && *remaining < count { + chunkLimit = *remaining + } + + results := reflect.New(sliceType).Interface() + + chunkQuery := query.Offset(offset).Limit(chunkLimit).(*Query) + err := chunkQuery.Find(results) + if err != nil { + return err + } + + resultsValue := reflect.ValueOf(results).Elem() + length := resultsValue.Len() + if length == 0 { + return nil + } + + if remaining != nil { + *remaining = max(*remaining-length, 0) + } + + values := make([]any, length) + for i := 0; i < length; i++ { + values[i] = resultsValue.Index(i).Interface() + } + + if err = callback(values); err != nil { + return err + } + + if length < chunkLimit { + return nil + } + + offset += chunkLimit + } + + return nil +} + +func (r *Query) ChunkByID(count int, callback func([]any) error) error { + return r.OrderedChunkByID(count, callback, false) +} + +func (r *Query) ChunkByIDDesc(count int, callback func([]any) error) error { + return r.OrderedChunkByID(count, callback, true) +} + +func (r *Query) OrderedChunkByID(count int, callback func([]any) error, descending bool) error { + if count <= 0 { + return errors.OrmQueryChunkZeroOrLess + } + + column := "id" + initialOffset := 0 + if r.conditions.offset != nil { + initialOffset = *r.conditions.offset + } + var remaining *int + if r.conditions.limit != nil { + limit := *r.conditions.limit + remaining = &limit + } + + destType := reflect.TypeOf(r.conditions.model) + sliceType := reflect.SliceOf(reflect.PointerTo(destType)) + var lastID any + page := 1 + + for remaining == nil || *remaining > 0 { + chunkLimit := count + if remaining != nil && *remaining < count { + chunkLimit = *remaining + } + + clone := r.addGlobalScopes() + + if initialOffset > 0 { + if page > 1 { + clone = clone.Offset(0).(*Query) + } else { + clone = clone.Offset(initialOffset).(*Query) + } + } + + if descending { + clone = clone.OrderByDesc(column).(*Query) + } else { + clone = clone.OrderBy(column).(*Query) + } + + if lastID != nil { + if descending { + clone = clone.Where(column+" < ?", lastID).(*Query) + } else { + clone = clone.Where(column+" > ?", lastID).(*Query) + } + } + clone = clone.Limit(chunkLimit).(*Query) + + query := clone.buildConditions() + results := reflect.New(sliceType).Interface() + + err := query.Find(results) + if err != nil { + return err + } + + resultsValue := reflect.ValueOf(results).Elem() + length := resultsValue.Len() + + if length == 0 { + break + } + + if remaining != nil { + *remaining = max(*remaining-length, 0) + } + + values := make([]any, length) + for i := 0; i < length; i++ { + values[i] = resultsValue.Index(i).Interface() + } + + lastRecord := values[length-1] + lastID = database.GetID(lastRecord) + + if err = callback(values); err != nil { + return err + } + + if length < chunkLimit { + break + } + + page++ + } + + return nil +} + func (r *Query) DB() (*sql.DB, error) { return r.instance.DB() } diff --git a/errors/list.go b/errors/list.go index a274ae218..61c488947 100644 --- a/errors/list.go +++ b/errors/list.go @@ -128,6 +128,7 @@ var ( OrmMissingWhereClause = New("WHERE conditions required") OrmNoDialectorsFound = New("no dialectors found") OrmQueryAssociationsConflict = New("cannot set orm.Associations and other fields at the same time") + OrmQueryChunkZeroOrLess = New("chunk count must be greater than 0") OrmQueryConditionRequired = New("query condition is required") OrmQueryEmptyId = New("id can't be empty") OrmQueryEmptyRelation = New("relation can't be empty") diff --git a/mocks/database/orm/Query.go b/mocks/database/orm/Query.go index b09772e27..14e2d3823 100644 --- a/mocks/database/orm/Query.go +++ b/mocks/database/orm/Query.go @@ -233,6 +233,147 @@ func (_c *Query_BeginTransaction_Call) RunAndReturn(run func() (orm.Query, error return _c } +// Chunk provides a mock function with given fields: count, callback +func (_m *Query) Chunk(count int, callback func([]any) error) error { + ret := _m.Called(count, callback) + + if len(ret) == 0 { + panic("no return value specified for Chunk") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int, func([]any) error) error); ok { + r0 = rf(count, callback) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Query_Chunk_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Chunk' +type Query_Chunk_Call struct { + *mock.Call +} + +// Chunk is a helper method to define mock.On call +// - count int +// - callback func([]any) error +func (_e *Query_Expecter) Chunk(count interface{}, callback interface{}) *Query_Chunk_Call { + return &Query_Chunk_Call{Call: _e.mock.On("Chunk", count, callback)} +} + +func (_c *Query_Chunk_Call) Run(run func(count int, callback func([]any) error)) *Query_Chunk_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int), args[1].(func([]any) error)) + }) + return _c +} + +func (_c *Query_Chunk_Call) Return(_a0 error) *Query_Chunk_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Query_Chunk_Call) RunAndReturn(run func(int, func([]any) error) error) *Query_Chunk_Call { + _c.Call.Return(run) + return _c +} + +// ChunkByID provides a mock function with given fields: count, callback +func (_m *Query) ChunkByID(count int, callback func([]any) error) error { + ret := _m.Called(count, callback) + + if len(ret) == 0 { + panic("no return value specified for ChunkByID") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int, func([]any) error) error); ok { + r0 = rf(count, callback) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Query_ChunkByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChunkByID' +type Query_ChunkByID_Call struct { + *mock.Call +} + +// ChunkByID is a helper method to define mock.On call +// - count int +// - callback func([]any) error +func (_e *Query_Expecter) ChunkByID(count interface{}, callback interface{}) *Query_ChunkByID_Call { + return &Query_ChunkByID_Call{Call: _e.mock.On("ChunkByID", count, callback)} +} + +func (_c *Query_ChunkByID_Call) Run(run func(count int, callback func([]any) error)) *Query_ChunkByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int), args[1].(func([]any) error)) + }) + return _c +} + +func (_c *Query_ChunkByID_Call) Return(_a0 error) *Query_ChunkByID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Query_ChunkByID_Call) RunAndReturn(run func(int, func([]any) error) error) *Query_ChunkByID_Call { + _c.Call.Return(run) + return _c +} + +// ChunkByIDDesc provides a mock function with given fields: count, callback +func (_m *Query) ChunkByIDDesc(count int, callback func([]any) error) error { + ret := _m.Called(count, callback) + + if len(ret) == 0 { + panic("no return value specified for ChunkByIDDesc") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int, func([]any) error) error); ok { + r0 = rf(count, callback) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Query_ChunkByIDDesc_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChunkByIDDesc' +type Query_ChunkByIDDesc_Call struct { + *mock.Call +} + +// ChunkByIDDesc is a helper method to define mock.On call +// - count int +// - callback func([]any) error +func (_e *Query_Expecter) ChunkByIDDesc(count interface{}, callback interface{}) *Query_ChunkByIDDesc_Call { + return &Query_ChunkByIDDesc_Call{Call: _e.mock.On("ChunkByIDDesc", count, callback)} +} + +func (_c *Query_ChunkByIDDesc_Call) Run(run func(count int, callback func([]any) error)) *Query_ChunkByIDDesc_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int), args[1].(func([]any) error)) + }) + return _c +} + +func (_c *Query_ChunkByIDDesc_Call) Return(_a0 error) *Query_ChunkByIDDesc_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Query_ChunkByIDDesc_Call) RunAndReturn(run func(int, func([]any) error) error) *Query_ChunkByIDDesc_Call { + _c.Call.Return(run) + return _c +} + // Commit provides a mock function with no fields func (_m *Query) Commit() error { ret := _m.Called() @@ -2797,6 +2938,54 @@ func (_c *Query_OrderByRaw_Call) RunAndReturn(run func(string) orm.Query) *Query return _c } +// OrderedChunkByID provides a mock function with given fields: count, callback, descending +func (_m *Query) OrderedChunkByID(count int, callback func([]interface{}) error, descending bool) error { + ret := _m.Called(count, callback, descending) + + if len(ret) == 0 { + panic("no return value specified for OrderedChunkByID") + } + + var r0 error + if rf, ok := ret.Get(0).(func(int, func([]interface{}) error, bool) error); ok { + r0 = rf(count, callback, descending) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Query_OrderedChunkByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OrderedChunkByID' +type Query_OrderedChunkByID_Call struct { + *mock.Call +} + +// OrderedChunkByID is a helper method to define mock.On call +// - count int +// - callback func([]interface{}) error +// - descending bool +func (_e *Query_Expecter) OrderedChunkByID(count interface{}, callback interface{}, descending interface{}) *Query_OrderedChunkByID_Call { + return &Query_OrderedChunkByID_Call{Call: _e.mock.On("OrderedChunkByID", count, callback, descending)} +} + +func (_c *Query_OrderedChunkByID_Call) Run(run func(count int, callback func([]interface{}) error, descending bool)) *Query_OrderedChunkByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int), args[1].(func([]interface{}) error), args[2].(bool)) + }) + return _c +} + +func (_c *Query_OrderedChunkByID_Call) Return(_a0 error) *Query_OrderedChunkByID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Query_OrderedChunkByID_Call) RunAndReturn(run func(int, func([]interface{}) error, bool) error) *Query_OrderedChunkByID_Call { + _c.Call.Return(run) + return _c +} + // Paginate provides a mock function with given fields: page, limit, dest, total func (_m *Query) Paginate(page int, limit int, dest interface{}, total *int64) error { ret := _m.Called(page, limit, dest, total) From 1ce05cbb9ad6a25908840a264966afa45dd8a411 Mon Sep 17 00:00:00 2001 From: arashackdev Date: Mon, 1 Dec 2025 04:27:39 +0100 Subject: [PATCH 2/3] fix: regenerate Query mockfile --- mocks/database/orm/Query.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/mocks/database/orm/Query.go b/mocks/database/orm/Query.go index 14e2d3823..2dc5d1730 100644 --- a/mocks/database/orm/Query.go +++ b/mocks/database/orm/Query.go @@ -234,7 +234,7 @@ func (_c *Query_BeginTransaction_Call) RunAndReturn(run func() (orm.Query, error } // Chunk provides a mock function with given fields: count, callback -func (_m *Query) Chunk(count int, callback func([]any) error) error { +func (_m *Query) Chunk(count int, callback func([]interface{}) error) error { ret := _m.Called(count, callback) if len(ret) == 0 { @@ -242,7 +242,7 @@ func (_m *Query) Chunk(count int, callback func([]any) error) error { } var r0 error - if rf, ok := ret.Get(0).(func(int, func([]any) error) error); ok { + if rf, ok := ret.Get(0).(func(int, func([]interface{}) error) error); ok { r0 = rf(count, callback) } else { r0 = ret.Error(0) @@ -258,14 +258,14 @@ type Query_Chunk_Call struct { // Chunk is a helper method to define mock.On call // - count int -// - callback func([]any) error +// - callback func([]interface{}) error func (_e *Query_Expecter) Chunk(count interface{}, callback interface{}) *Query_Chunk_Call { return &Query_Chunk_Call{Call: _e.mock.On("Chunk", count, callback)} } -func (_c *Query_Chunk_Call) Run(run func(count int, callback func([]any) error)) *Query_Chunk_Call { +func (_c *Query_Chunk_Call) Run(run func(count int, callback func([]interface{}) error)) *Query_Chunk_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(func([]any) error)) + run(args[0].(int), args[1].(func([]interface{}) error)) }) return _c } @@ -275,13 +275,13 @@ func (_c *Query_Chunk_Call) Return(_a0 error) *Query_Chunk_Call { return _c } -func (_c *Query_Chunk_Call) RunAndReturn(run func(int, func([]any) error) error) *Query_Chunk_Call { +func (_c *Query_Chunk_Call) RunAndReturn(run func(int, func([]interface{}) error) error) *Query_Chunk_Call { _c.Call.Return(run) return _c } // ChunkByID provides a mock function with given fields: count, callback -func (_m *Query) ChunkByID(count int, callback func([]any) error) error { +func (_m *Query) ChunkByID(count int, callback func([]interface{}) error) error { ret := _m.Called(count, callback) if len(ret) == 0 { @@ -289,7 +289,7 @@ func (_m *Query) ChunkByID(count int, callback func([]any) error) error { } var r0 error - if rf, ok := ret.Get(0).(func(int, func([]any) error) error); ok { + if rf, ok := ret.Get(0).(func(int, func([]interface{}) error) error); ok { r0 = rf(count, callback) } else { r0 = ret.Error(0) @@ -305,14 +305,14 @@ type Query_ChunkByID_Call struct { // ChunkByID is a helper method to define mock.On call // - count int -// - callback func([]any) error +// - callback func([]interface{}) error func (_e *Query_Expecter) ChunkByID(count interface{}, callback interface{}) *Query_ChunkByID_Call { return &Query_ChunkByID_Call{Call: _e.mock.On("ChunkByID", count, callback)} } -func (_c *Query_ChunkByID_Call) Run(run func(count int, callback func([]any) error)) *Query_ChunkByID_Call { +func (_c *Query_ChunkByID_Call) Run(run func(count int, callback func([]interface{}) error)) *Query_ChunkByID_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(func([]any) error)) + run(args[0].(int), args[1].(func([]interface{}) error)) }) return _c } @@ -322,13 +322,13 @@ func (_c *Query_ChunkByID_Call) Return(_a0 error) *Query_ChunkByID_Call { return _c } -func (_c *Query_ChunkByID_Call) RunAndReturn(run func(int, func([]any) error) error) *Query_ChunkByID_Call { +func (_c *Query_ChunkByID_Call) RunAndReturn(run func(int, func([]interface{}) error) error) *Query_ChunkByID_Call { _c.Call.Return(run) return _c } // ChunkByIDDesc provides a mock function with given fields: count, callback -func (_m *Query) ChunkByIDDesc(count int, callback func([]any) error) error { +func (_m *Query) ChunkByIDDesc(count int, callback func([]interface{}) error) error { ret := _m.Called(count, callback) if len(ret) == 0 { @@ -336,7 +336,7 @@ func (_m *Query) ChunkByIDDesc(count int, callback func([]any) error) error { } var r0 error - if rf, ok := ret.Get(0).(func(int, func([]any) error) error); ok { + if rf, ok := ret.Get(0).(func(int, func([]interface{}) error) error); ok { r0 = rf(count, callback) } else { r0 = ret.Error(0) @@ -352,14 +352,14 @@ type Query_ChunkByIDDesc_Call struct { // ChunkByIDDesc is a helper method to define mock.On call // - count int -// - callback func([]any) error +// - callback func([]interface{}) error func (_e *Query_Expecter) ChunkByIDDesc(count interface{}, callback interface{}) *Query_ChunkByIDDesc_Call { return &Query_ChunkByIDDesc_Call{Call: _e.mock.On("ChunkByIDDesc", count, callback)} } -func (_c *Query_ChunkByIDDesc_Call) Run(run func(count int, callback func([]any) error)) *Query_ChunkByIDDesc_Call { +func (_c *Query_ChunkByIDDesc_Call) Run(run func(count int, callback func([]interface{}) error)) *Query_ChunkByIDDesc_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(func([]any) error)) + run(args[0].(int), args[1].(func([]interface{}) error)) }) return _c } @@ -369,7 +369,7 @@ func (_c *Query_ChunkByIDDesc_Call) Return(_a0 error) *Query_ChunkByIDDesc_Call return _c } -func (_c *Query_ChunkByIDDesc_Call) RunAndReturn(run func(int, func([]any) error) error) *Query_ChunkByIDDesc_Call { +func (_c *Query_ChunkByIDDesc_Call) RunAndReturn(run func(int, func([]interface{}) error) error) *Query_ChunkByIDDesc_Call { _c.Call.Return(run) return _c } From 9be5fb67df47e185b4918d1148290560c2eb07a3 Mon Sep 17 00:00:00 2001 From: arashackdev Date: Tue, 2 Dec 2025 22:03:21 +0100 Subject: [PATCH 3/3] refactor: update Chunk and ChunkByID methods for improved pagination handling - Enhanced ChunkByID method documentation to clarify its purpose. - Removed the OrderedChunkByID method and replaced its usage with an internal orderedChunkByID method. - Added validation for nil model conditions in Chunk and orderedChunkByID methods. - Updated mock definitions to reflect the removal of OrderedChunkByID. --- contracts/database/orm/orm.go | 5 ++-- database/gorm/query.go | 20 ++++++++++++--- mocks/database/orm/Query.go | 48 ----------------------------------- 3 files changed, 18 insertions(+), 55 deletions(-) diff --git a/contracts/database/orm/orm.go b/contracts/database/orm/orm.go index f95b18316..617bc9729 100644 --- a/contracts/database/orm/orm.go +++ b/contracts/database/orm/orm.go @@ -45,7 +45,8 @@ type Query interface { BeginTransaction() (Query, error) // Chunk processes a given number of records in batches. Chunk(count int, callback func([]any) error) error - // Chunk the results of a query by comparing numeric IDs. + // ChunkByID processes records in batches by comparing numeric IDs in ascending order. + // This avoids issues with offset-based pagination when records are added or deleted during processing. ChunkByID(count int, callback func([]any) error) error // ChunkByIDDesc processes a given number of records in batches, ordered by ID in descending order. ChunkByIDDesc(count int, callback func([]any) error) error @@ -126,8 +127,6 @@ type Query interface { OrderByDesc(column string) Query // OrderByRaw specifies the order should be raw. OrderByRaw(raw string) Query - // OrderedChunkByID processes a given number of records in batches, ordered by ID. - OrderedChunkByID(count int, callback func([]any) error, descending bool) error // OrWhere add an "or where" clause to the query. OrWhere(query any, args ...any) Query // OrWhereBetween adds an "or where column between x and y" clause to the query. diff --git a/database/gorm/query.go b/database/gorm/query.go index d61df7a26..66f99ced5 100644 --- a/database/gorm/query.go +++ b/database/gorm/query.go @@ -194,6 +194,14 @@ func (r *Query) Chunk(count int, callback func([]any) error) error { return errors.OrmQueryChunkZeroOrLess } + if r.conditions.model == nil { + return errors.OrmQueryInvalidModel.Args("nil") + } + + initialOffset := 0 + if r.conditions.offset != nil { + initialOffset = *r.conditions.offset + } var remaining *int if r.conditions.limit != nil { limit := *r.conditions.limit @@ -204,7 +212,7 @@ func (r *Query) Chunk(count int, callback func([]any) error) error { destType := reflect.TypeOf(r.conditions.model) sliceType := reflect.SliceOf(reflect.PointerTo(destType)) - offset := 0 + offset := initialOffset for remaining == nil || *remaining > 0 { chunkLimit := count @@ -250,18 +258,22 @@ func (r *Query) Chunk(count int, callback func([]any) error) error { } func (r *Query) ChunkByID(count int, callback func([]any) error) error { - return r.OrderedChunkByID(count, callback, false) + return r.orderedChunkByID(count, callback, false) } func (r *Query) ChunkByIDDesc(count int, callback func([]any) error) error { - return r.OrderedChunkByID(count, callback, true) + return r.orderedChunkByID(count, callback, true) } -func (r *Query) OrderedChunkByID(count int, callback func([]any) error, descending bool) error { +func (r *Query) orderedChunkByID(count int, callback func([]any) error, descending bool) error { if count <= 0 { return errors.OrmQueryChunkZeroOrLess } + if r.conditions.model == nil { + return errors.OrmQueryInvalidModel.Args("nil") + } + column := "id" initialOffset := 0 if r.conditions.offset != nil { diff --git a/mocks/database/orm/Query.go b/mocks/database/orm/Query.go index 2dc5d1730..84e76199e 100644 --- a/mocks/database/orm/Query.go +++ b/mocks/database/orm/Query.go @@ -2938,54 +2938,6 @@ func (_c *Query_OrderByRaw_Call) RunAndReturn(run func(string) orm.Query) *Query return _c } -// OrderedChunkByID provides a mock function with given fields: count, callback, descending -func (_m *Query) OrderedChunkByID(count int, callback func([]interface{}) error, descending bool) error { - ret := _m.Called(count, callback, descending) - - if len(ret) == 0 { - panic("no return value specified for OrderedChunkByID") - } - - var r0 error - if rf, ok := ret.Get(0).(func(int, func([]interface{}) error, bool) error); ok { - r0 = rf(count, callback, descending) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Query_OrderedChunkByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OrderedChunkByID' -type Query_OrderedChunkByID_Call struct { - *mock.Call -} - -// OrderedChunkByID is a helper method to define mock.On call -// - count int -// - callback func([]interface{}) error -// - descending bool -func (_e *Query_Expecter) OrderedChunkByID(count interface{}, callback interface{}, descending interface{}) *Query_OrderedChunkByID_Call { - return &Query_OrderedChunkByID_Call{Call: _e.mock.On("OrderedChunkByID", count, callback, descending)} -} - -func (_c *Query_OrderedChunkByID_Call) Run(run func(count int, callback func([]interface{}) error, descending bool)) *Query_OrderedChunkByID_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(func([]interface{}) error), args[2].(bool)) - }) - return _c -} - -func (_c *Query_OrderedChunkByID_Call) Return(_a0 error) *Query_OrderedChunkByID_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *Query_OrderedChunkByID_Call) RunAndReturn(run func(int, func([]interface{}) error, bool) error) *Query_OrderedChunkByID_Call { - _c.Call.Return(run) - return _c -} - // Paginate provides a mock function with given fields: page, limit, dest, total func (_m *Query) Paginate(page int, limit int, dest interface{}, total *int64) error { ret := _m.Called(page, limit, dest, total)