sdbc/insert_scope.go

39 lines
668 B
Go
Raw Normal View History

2023-09-10 16:07:03 +00:00
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
}