Skip to content

Instantly share code, notes, and snippets.

@bketelsen
Last active March 12, 2016 20:43
Show Gist options
  • Save bketelsen/48accd139bafb01152fb to your computer and use it in GitHub Desktop.
Save bketelsen/48accd139bafb01152fb to your computer and use it in GitHub Desktop.
package design
import (
"github.com/goadesign/gorma"
. "github.com/goadesign/gorma/dsl"
)
var _ = StorageGroup("CongoStorageGroup", func() {
Description("This is the global storage group")
Store("postgres", gorma.Postgres, func() {
Description("This is the Postgres relational store")
Roles(func() {
Role("Admin", func() {
Scope("proposal:accept")
Scope("proposal:reject")
})
Role("User", func() {
Scope("proposal:create")
Scope("proposal:update")
Scope("proposal:delete")
})
})
Model("User", func() {
BuildsFrom(func() {
Payload("user", "create")
Payload("user", "update")
})
RendersTo(User)
Description("User Model")
HasMany("Reviews", "Review")
HasMany("Proposals", "Proposal")
Field("id", gorma.Integer, func() {
PrimaryKey()
Description("This is the User Model PK field")
})
Roler(func(){
Default("User")
RoleField("role")
})
Field("created_at", gorma.Timestamp, func() {})
Field("updated_at", gorma.Timestamp, func() {})
Field("deleted_at", gorma.NullableTimestamp, func() {})
})
Model("Proposal", func() {
BuildsFrom(func() {
Payload("proposal", "create")
Payload("proposal", "update")
})
RendersTo(Proposal)
Description("Proposal Model")
BelongsTo("User")
HasMany("Reviews", "Review")
Field("id", gorma.Integer, func() {
PrimaryKey()
Description("This is the Payload Model PK field")
})
Field("created_at", gorma.Timestamp, func() {})
Field("updated_at", gorma.Timestamp, func() {})
Field("deleted_at", gorma.NullableTimestamp, func() {})
})
Model("Review", func() {
BuildsFrom(func() {
Payload("review", "create")
Payload("review", "update")
})
RendersTo(Review)
Description("Review Model")
BelongsTo("User")
BelongsTo("Proposal")
Field("id", gorma.Integer, func() {
PrimaryKey()
Description("This is the Review Model PK field")
})
Field("created_at", gorma.Timestamp, func() {})
Field("updated_at", gorma.Timestamp, func() {})
Field("deleted_at", gorma.NullableTimestamp, func() {})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment