Use model/attribute terminology in CUE files

This commit is contained in:
Denis Arh
2022-08-01 19:01:19 +02:00
parent 353d6ad37d
commit 89eefa5bc2
42 changed files with 109 additions and 109 deletions
@@ -4,13 +4,13 @@ import (
"strings"
)
#Struct: {
#Model: {
// Each field can be
[name=_]: {"name": name} & #StructField
[name=_]: {"name": name} & #ModelAttribute
}
// logic in struct fields is a bit different
#StructField: {
#ModelAttribute: {
name: #ident
_words: strings.Replace(strings.Replace(name, "_", " ", -1), ".", " ", -1)
@@ -35,10 +35,10 @@ import (
primaryKey: bool | *false
ignoreCase: bool | *false
#StructJsonTag
#ModelAttributeJsonTag
}
IdField: #StructField & {
IdField: #ModelAttribute & {
// Expecting ID field to always have name ID
name: "id"
expIdent: "ID"
@@ -49,7 +49,7 @@ IdField: #StructField & {
goType: "uint64"
}
HandleField: #StructField & {
HandleField: #ModelAttribute & {
// Expecting ID field to always have name handle
name: "handle"
unique: true
@@ -58,17 +58,17 @@ HandleField: #StructField & {
goType: "string"
}
SortableTimestampField: #StructField & {
SortableTimestampField: #ModelAttribute & {
sortable: true
goType: "time.Time"
}
SortableTimestampNilField: #StructField & {
SortableTimestampNilField: #ModelAttribute & {
sortable: true
goType: "*time.Time"
}
#StructJsonTag: {
#ModelAttributeJsonTag: {
name: string
_specs: {field: string | *name, omitEmpty: bool | *false, "string": bool | *false}
+3 -3
View File
@@ -18,11 +18,11 @@ import (
// Fully qualified resource name
fqrn: string | *(platform + "::" + component + ":" + handle)
struct: #Struct
model: #Model
filter: {
"expIdent": #expIdent | *"\(expIdent)Filter"
struct: #Struct
model: #Model
// generate filtering by-nil-state for the specified fields
"byNilState": [...string]
@@ -86,7 +86,7 @@ import (
api?: {
lookups: [...{
_expFields: [ for f in fields {strings.ToTitle(struct[f].expIdent)}]
_expFields: [ for f in fields {strings.ToTitle(model[f].expIdent)}]
"expIdent": "Lookup\(store.expIdent)By" + strings.Join(_expFields, "")
description: string | *""