goadesign / goadesign/gorma

build error when I use ArrayOf in payload and Gorma

Open
#116 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
141
Forks
35
PR merge metrics
No merged PRs in 30d

Description

We're expecting in one of our payloads and object that has basic attributes and array of objects in it. . However, I get these errors when we use gorma.

**models/clc.go:178: cannot use *payload.Containers (type string) as type []Container in assignment
models/clc.go:203: cannot use *payload.Containers (type string) as type []Container in assignment**

This is how the payload is defined

```
`var ClcPayload = Type("ClcPayload", func() {
Attribute("name", String, func() {
MinLength(1)
MaxLength(1024)
})
Attribute("labels", func(){
ArrayOf(LabelPayload)
})
Attribute("description", String, func(){
MinLength(0)
MaxLength(1024)
})
Attribute("replicas", Integer, func(){
Minimum(1)
Maximum(10)
})
Attribute("containers", func(){
ArrayOf(ContainerPayload)
})
})`

```

```
var ContainerPayload = Type("ContainerPayload", func() {
Attribute("name", String, func() {
MinLength(1)
MaxLength(1024)
})
Attribute("labels", func(){
ArrayOf(LabelPayload)
})
Attribute("description", String, func(){
MinLength(0)
MaxLength(1024)
})
Attribute("image_url", String)

Attribute("ports", func(){
ArrayOf(PortPayload)
})

Attribute("envs", func(){
ArrayOf(EnvPayload)
})

Attribute("commands", func(){
ArrayOf(String)
})
Attribute("icus", Integer)
Attribute("memory", Integer)
Attribute("replicas", Integer, func(){
Minimum(1)
Maximum(10)
})
//Attribute("volumes", ArrayOf(VolumePayload))
})`

```

This is the definition of our data model

```
Model("Clc", func() {
BuildsFrom(func() {
Payload("clc", "create")
Payload("clc", "update")
})
RendersTo(Clc)
HasMany("Containers", "Container")
Description("Colocated Container Model Description")
Field("id", gorma.UUID, func() {
PrimaryKey()
Description("This is the Clc Model PK field")
})
BelongsTo("Service")
})
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.