@@ -26,9 +26,6 @@ type InsertStatement interface {
2626
2727 // ExcludedColumns returns the columns to be excluded from the INSERT statement.
2828 ExcludedColumns () []string
29-
30- // apply implements the InsertOption interface and applies itself to the given options.
31- apply (opts * insertOptions )
3229}
3330
3431// NewInsertStatement returns a new insertStatement for the given entity.
@@ -80,10 +77,6 @@ func (i *insertStatement) ExcludedColumns() []string {
8077 return i .excludedColumns
8178}
8279
83- func (i * insertStatement ) apply (opts * insertOptions ) {
84- opts .stmt = i
85- }
86-
8780// InsertSelectStatement is the interface for building INSERT SELECT statements.
8881type InsertSelectStatement interface {
8982 // Into sets the table name for the INSERT SELECT statement.
@@ -176,24 +169,21 @@ func (i *insertSelectStatement) Select() SelectStatement {
176169 return i .selectStmt
177170}
178171
179- // InsertOption is the interface for functional options for InsertStreamed.
180- type InsertOption interface {
181- // apply applies the option to the given insertOptions.
182- apply (opts * insertOptions )
183- }
172+ // InsertOption is a functional option for InsertStreamed().
173+ type InsertOption func (opts * insertOptions )
184174
185- // InsertOptionFunc is a function type that implements the InsertOption interface .
186- type InsertOptionFunc func ( opts * insertOptions )
187-
188- func ( f InsertOptionFunc ) apply ( opts * insertOptions ) {
189- f ( opts )
175+ // WithInsertStatement sets the INSERT statement to be used for inserting entities .
176+ func WithInsertStatement ( stmt InsertStatement ) InsertOption {
177+ return func ( opts * insertOptions ) {
178+ opts . stmt = stmt
179+ }
190180}
191181
192182// WithOnInsert sets the onInsert callbacks for a successful INSERT statement.
193183func WithOnInsert (onInsert ... OnSuccess [any ]) InsertOption {
194- return InsertOptionFunc ( func (opts * insertOptions ) {
184+ return func (opts * insertOptions ) {
195185 opts .onInsert = onInsert
196- })
186+ }
197187}
198188
199189// insertOptions stores the options for InsertStreamed.
0 commit comments