ocket8888 commented on code in PR #6996:
URL: https://github.com/apache/trafficcontrol/pull/6996#discussion_r938022975
##########
lib/go-tc/server_server_capability.go:
##########
@@ -27,6 +27,12 @@ type ServerServerCapability struct {
ServerCapability *string `json:"serverCapability"
db:"server_capability"`
}
+// MultipleServerCapabilities represents an association between a server and
list of server capabilities.
+type MultipleServerCapabilities struct {
+ ServerID int `json:"serverId" db:"server"`
+ ServerCapability []string `json:"serverCapability"
db:"server_capability"`
Review Comment:
The database column is singular because each server capability is its own
row - but that's not how the data is represented in this endpoint. If it
matched the database layout it'd be more like:
```json
[{
"serverId": 1,
"serverCapability": "foo"
},{
"serverId": 1,
"serverCapability": "bar"
}]
```
in which case a singular name (`serverCapability`) makes sense, because it
only contains one. But our API representation doesn't exactly reflect the
database table model - and it shouldn't, necessarily. The database is an
implementation detail that consumers of the API shouldn't have to know or care
about. For that reason, the JSON tag doesn't have to match the db tag; both
should just do what makes sense, which just so happens to often be similar.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]