MCPcopy
hub / github.com/gogf/gf / Fields

Method Fields

database/gdb/gdb_model_fields.go:26–37  ·  view source on GitHub ↗

Fields appends `fieldNamesOrMapStruct` to the operation fields of the model, multiple fields joined using char ','. The parameter `fieldNamesOrMapStruct` can be type of string/map/*map/struct/*struct. Example: Fields("id", "name", "age") Fields([]string{"id", "name", "age"}) Fields(map[string]any{"

(fieldNamesOrMapStruct ...any)

Source from the content-addressed store, hash-verified

24// Fields(map[string]any{"id":1, "name":"john", "age":18})
25// Fields(User{Id: 1, Name: "john", Age: 18}).
26func (m *Model) Fields(fieldNamesOrMapStruct ...any) *Model {
27 length := len(fieldNamesOrMapStruct)
28 if length == 0 {
29 return m
30 }
31 fields := m.filterFieldsFrom(m.tablesInit, fieldNamesOrMapStruct...)
32 if len(fields) == 0 {
33 return m
34 }
35 model := m.getModel()
36 return model.appendToFields(fields...)
37}
38
39// FieldsPrefix performs as function Fields but add extra prefix for each field.
40func (m *Model) FieldsPrefix(prefixOrAlias string, fieldNamesOrMapStruct ...any) *Model {

Callers 15

ArrayMethod · 0.95
doStructMethod · 0.95
doStructsMethod · 0.95
ScanListMethod · 0.95
ValueMethod · 0.95
ExistMethod · 0.95
CountColumnMethod · 0.95
MinMethod · 0.95
MaxMethod · 0.95
AvgMethod · 0.95
SumMethod · 0.95
Test_DB_ToJsonFunction · 0.80

Calls 3

filterFieldsFromMethod · 0.95
getModelMethod · 0.95
appendToFieldsMethod · 0.80

Tested by 15

Test_DB_ToJsonFunction · 0.64
Test_DB_ToXmlFunction · 0.64
Test_DB_ToStringMapFunction · 0.64
Test_DB_ToIntMapFunction · 0.64
Test_DB_ToUintMapFunction · 0.64
Test_DB_ToStringRecordFunction · 0.64
Test_DB_ToIntRecordFunction · 0.64
Test_DB_ToUintRecordFunction · 0.64
Test_DB_TableFieldFunction · 0.64
Test_TableNameIsKeywordFunction · 0.64
Test_Model_InsertFunction · 0.64
Test_Model_UpdateFunction · 0.64