-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hof/docs: do some writing on data models
- Loading branch information
Showing
9 changed files
with
215 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
MyModels: { | ||
@datamodel() | ||
|
||
foo: "string" | ||
... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
MyModels: { | ||
#hof: datamodel: root: true | ||
|
||
foo: "string" | ||
... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
import "github.com/hofstadter-io/hof/schema/dm" | ||
|
||
MyModels: dm.Datamodel & { | ||
foo: "string" | ||
... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/hofstadter-io/hof/schema/dm/sql" | ||
"github.com/hofstadter-io/supacode/gen" | ||
"github.com/hofstadter-io/supacode/schema" | ||
) | ||
|
||
MyGen: gen.Generator & { | ||
@gen() | ||
Datamodel: MyModels | ||
App: MyApp | ||
} | ||
|
||
MyModels: sql.Datamodel & { | ||
@datamodel() | ||
Models: { | ||
... | ||
} | ||
} | ||
|
||
MyApp: schema.App & { | ||
// sometimes a module author will place the datamodel here | ||
// or provide a custom datamodel specific to their generator | ||
... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MyModels: { | ||
@datamodel() | ||
|
||
Models: { | ||
@history() | ||
|
||
User: { | ||
Fields: { | ||
@history() | ||
... | ||
} | ||
} | ||
|
||
... | ||
} | ||
|
||
Views: { | ||
@history() | ||
|
||
... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package schema | ||
|
||
import ( | ||
"github.com/hofstadter-io/hof/schema/dm/sql" | ||
"github.com/hofstadter-io/hof/schema/dm/enrichers:go" | ||
"github.com/hofstadter-io/hof/schema/dm/enrichers:py" | ||
) | ||
|
||
Datamodel: sql.Datamodel & { | ||
Models: { | ||
@history() | ||
|
||
// apply to each "model" (CUE pattern constraint) | ||
[string]: { | ||
Fields: { | ||
@history() | ||
|
||
// apply to each "field" (CUE pattern constraint) | ||
[string]: go.FieldEnricher | ||
[string]: py.FieldEnricher | ||
|
||
// These will add GoType and PyType to the "model" "field" | ||
... | ||
} | ||
} | ||
... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.