Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chunk ¶
func Chunk[Q chunkImp[Q, T], T any](ctx context.Context, query Q, chunk int, fn func(batchIndex int, items []*T) error) error
Chunk 分批处理数据 example:
client, err := ent.Open("mysql", os.Getenv("ACCOUNT_DB_DSN")) if err != nil { panic(err) } ctx := context.Background() err = enthelper.Chunk(ctx, client.Account.Query(), 100, func(batchIndex int, items []*ent.Account) error { for i, item := range items { fmt.Println(batch, i, item.Email) } return nil })
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.