gf/database/gdb/gdb_model_option.go
2021-08-13 11:28:47 +08:00

73 lines
2.3 KiB
Go

// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gdb
const (
optionOmitNil = optionOmitNilWhere | optionOmitNilData
optionOmitEmpty = optionOmitEmptyWhere | optionOmitEmptyData
optionOmitEmptyWhere = 1 << iota // 8
optionOmitEmptyData // 16
optionOmitNilWhere // 32
optionOmitNilData // 64
)
// Option adds extra operation option for the model.
// Deprecated, use separate operations instead.
func (m *Model) Option(option int) *Model {
model := m.getModel()
model.option = model.option | option
return model
}
// OmitEmpty sets optionOmitEmpty option for the model, which automatically filers
// the data and where parameters for `empty` values.
func (m *Model) OmitEmpty() *Model {
model := m.getModel()
model.option = model.option | optionOmitEmpty
return model
}
// OmitEmptyWhere sets optionOmitEmptyWhere option for the model, which automatically filers
// the Where/Having parameters for `empty` values.
func (m *Model) OmitEmptyWhere() *Model {
model := m.getModel()
model.option = model.option | optionOmitEmptyWhere
return model
}
// OmitEmptyData sets optionOmitEmptyData option for the model, which automatically filers
// the Data parameters for `empty` values.
func (m *Model) OmitEmptyData() *Model {
model := m.getModel()
model.option = model.option | optionOmitEmptyData
return model
}
// OmitNil sets optionOmitNil option for the model, which automatically filers
// the data and where parameters for `nil` values.
func (m *Model) OmitNil() *Model {
model := m.getModel()
model.option = model.option | optionOmitNil
return model
}
// OmitNilWhere sets optionOmitNilWhere option for the model, which automatically filers
// the Where/Having parameters for `nil` values.
func (m *Model) OmitNilWhere() *Model {
model := m.getModel()
model.option = model.option | optionOmitNilWhere
return model
}
// OmitNilData sets optionOmitNilData option for the model, which automatically filers
// the Data parameters for `nil` values.
func (m *Model) OmitNilData() *Model {
model := m.getModel()
model.option = model.option | optionOmitNilData
return model
}