photoprism/internal/entity/auth_user_report.go
Michael Mayer 60162b3fc5 Auth: Refactor user management API and CLI commands #98
Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-03-08 23:30:39 +01:00

32 lines
525 B
Go

package entity
import (
"fmt"
)
// Report returns the entity values as rows.
func (m *User) 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 {
s := fmt.Sprintf("%#v", v)
// Skip empty values?
if !skipEmpty || s != "" {
rows = append(rows, []string{k, s})
}
}
return rows, cols
}