Skip to content

Commit

Permalink
update data model schema, small changes in cuetils
Browse files Browse the repository at this point in the history
  • Loading branch information
verdverm committed Nov 21, 2020
1 parent 7938f03 commit 971d190
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/cuetils/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func PrintCueValue(val cue.Value) (string, error) {
return string(bytes), nil
}

func ValueToSyntaxString(val cue.Value) (string, error) {
src, err := format.Node(val.Syntax())
func ValueToSyntaxString(val cue.Value, opts ...cue.Option) (string, error) {
src, err := format.Node(val.Syntax(opts...))
str := string(src)
return str, err
}
Expand Down
2 changes: 2 additions & 0 deletions lib/cuetils/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ func (CRT *CueRuntime) load() (err error) {
// fmt.Println(i, "valued", V)

// Decode? we want to be lazy
/*
err = V.Decode(&CRT.Value)
if err != nil {
errs = append(errs, err)
continue
}
*/

// fmt.Println(i, "decoded", CRT.Value)

Expand Down
5 changes: 5 additions & 0 deletions schema/datamodel.cue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import "strings"

ORM: bool | *false
SoftDelete: bool | *false
Permissioned: bool | *true

Views?: #Views

Expand All @@ -48,6 +49,10 @@ import "strings"
fieldName: string | *strings.ToCamel(Name)
FieldName: string | *strings.ToTitle(Name)

type: string

validation?: [string]: _

private: bool | *false

...
Expand Down
18 changes: 12 additions & 6 deletions schema/datatypes.cue
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@ package schema
type: "uuid"
nullable: bool | *false
unique: bool | *true
generate: bool | *true
default: "gen_random_uuid()"
validation: {
format: "email"
}
...
}

#CUID: #Field & {
type: "cuid"
nullable: bool | *false
unique: bool | *true
generate: bool | *true
...
}

#Bool: #Field & {
type: "bool"
default: bool | *false
default: string | *"false"
nullable: bool | *false
...
}
Expand All @@ -40,6 +42,9 @@ package schema
unique: bool | *false
nullable: bool | *false
default?: string
validation: {
max: length
}
...
}

Expand All @@ -51,13 +56,14 @@ package schema
...
}

#Password: #Field & {
type: "text"
#Password: #String & {
bcrypt: true
}

#Email: #String & {
validation: "email"
validation: {
format: "email"
}
unique: true
...
}
Expand Down

0 comments on commit 971d190

Please sign in to comment.