39 lines
668 B
Go
39 lines
668 B
Go
package sdbc
|
|
|
|
import "context"
|
|
|
|
type insert struct {
|
|
scope *scope
|
|
sdbc *sdbc
|
|
ctx context.Context
|
|
selectOpts []interface{}
|
|
omitOpts []string
|
|
}
|
|
|
|
func (i *insert) SetContext(ctx context.Context) {
|
|
i.ctx = ctx
|
|
}
|
|
|
|
func (i *insert) SetSelect(selects ...any) {
|
|
i.selectOpts = selects
|
|
}
|
|
|
|
func (i *insert) SetOmit(omits ...string) {
|
|
i.omitOpts = omits
|
|
}
|
|
|
|
func (i *insert) InsertOne(doc any) error {
|
|
db := i.sdbc.client
|
|
if len(i.selectOpts) != 0 {
|
|
db.Select(i.selectOpts[0], i.selectOpts[1:]...)
|
|
}
|
|
if len(i.omitOpts) != 0 {
|
|
db.Omit(i.omitOpts...)
|
|
}
|
|
return db.Create(doc).Error
|
|
}
|
|
|
|
func (i *insert) InsertMany(docs any) error {
|
|
return nil
|
|
}
|