improve gdb.Model.Fields/FieldsEx for package gdb
@@ -24,19 +24,25 @@ func (m *Model) Filter() *Model {
}
// Fields sets the operation fields of the model, multiple fields joined using char ','.
-func (m *Model) Fields(fields string) *Model {
+func (m *Model) Fields(fields ...string) *Model {
+ if len(fields) > 0 {
model := m.getModel()
- model.fields = fields
+ model.fields = gstr.Join(fields, ",")
return model
}
+ return m
+}
// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
// Note that this function supports only single table operations.
-func (m *Model) FieldsEx(fields string) *Model {
+func (m *Model) FieldsEx(fields ...string) *Model {
+ if len(fields) > 0 {
model := m.getModel()
- model.fieldsEx = fields
+ model.fieldsEx = gstr.Join(fields, ",")
return model
}
+ return m
+}
// Deprecated, use GetFieldsStr instead.
// This function name confuses the user that it was a chaining function.
