first commit
This commit is contained in:
35
go-api/internal/domain/record.go
Normal file
35
go-api/internal/domain/record.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package domain
|
||||
|
||||
// Record is one row as the API exposes it: the frontend's exact field names
|
||||
// mapped to JSON-ready values.
|
||||
//
|
||||
// A map rather than a struct per resource. The frontend treats every record as
|
||||
// an opaque bag of fields it round-trips unchanged — `store.js` stores whatever
|
||||
// it was handed and returns a clone — and fourteen structs totalling ~350
|
||||
// fields would add a transcription risk without adding a guarantee. Typing
|
||||
// lives in the Column descriptors instead, where validation and SQL both read
|
||||
// it from one place.
|
||||
type Record map[string]any
|
||||
|
||||
// ListParams is a parsed, validated collection query.
|
||||
type ListParams struct {
|
||||
Sort string // column name, without the leading '-'
|
||||
Desc bool
|
||||
Limit int
|
||||
Offset int
|
||||
Filters []Filter
|
||||
}
|
||||
|
||||
// Filter is one equality or membership test. See api-contract.md §6.
|
||||
type Filter struct {
|
||||
Column *Column
|
||||
Values []string // len > 1 means IN
|
||||
}
|
||||
|
||||
// Page is a collection result plus the metadata the envelope reports.
|
||||
type Page struct {
|
||||
Records []Record
|
||||
Total int
|
||||
Limit int
|
||||
Offset int
|
||||
}
|
||||
Reference in New Issue
Block a user