gorma icon indicating copy to clipboard operation
gorma copied to clipboard

confusing docs for `BuildsFrom`

Open jeffwillette opened this issue 8 years ago • 1 comments

I am a bit confused on what I should do with BuildsFrom since the docs seem to say that I can put a raw type identifier in there...

DOCS

func BuildsFrom

func BuildsFrom(dsl func())
BuildsFrom informs Gorma that this model will be populated from a Goa UserType. Conversion functions will be generated to convert from the payload to the model.

Usage: BuildsFrom(YourType)

Fields not in YourType that you want in your model must be added explicitly with the Field DSL.

If I try BuildsFrom(Type) I get the following error:

/design/models_design.go:61: cannot use Document (type *design.UserTypeDefinition) as type func() in argument to dsl.BuildsFrom

I know BuildsFrom is generally used like below, but would like some clarification

BuildsFrom(func() {
    Payload("[resource]", "[action]")
})

jeffwillette avatar May 09 '17 14:05 jeffwillette

I think it would be much cleaner to use type directly instead of resource-action pair. e.g

BuildsFrom(func() {
    Payload(User) // instead of Payload("user", "update")
})

josephbuchma avatar Sep 17 '17 17:09 josephbuchma