2022-10-03 22:59:29 +02:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Report returns the entity values as rows.
|
|
|
|
func (m *Session) Report(skipEmpty bool) (rows [][]string, cols []string) {
|
|
|
|
cols = []string{"Name", "Value"}
|
|
|
|
|
|
|
|
// Extract model values.
|
|
|
|
values, _, err := ModelValues(m, "ID")
|
|
|
|
|
|
|
|
// Ok?
|
|
|
|
if err != nil {
|
|
|
|
return rows, cols
|
|
|
|
}
|
|
|
|
|
|
|
|
rows = make([][]string, 0, len(values))
|
|
|
|
|
|
|
|
for k, v := range values {
|
2023-03-08 23:30:39 +01:00
|
|
|
s := fmt.Sprintf("%#v", v)
|
2022-10-03 22:59:29 +02:00
|
|
|
|
|
|
|
// Skip empty values?
|
|
|
|
if !skipEmpty || s != "" {
|
|
|
|
rows = append(rows, []string{k, s})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rows, cols
|
|
|
|
}
|