-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add new getting-started sections; some code reorg & fmt
- Loading branch information
Tony Worm
committed
May 7, 2024
1 parent
b28c0aa
commit 20f06d3
Showing
21 changed files
with
1,070 additions
and
68 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
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 @@ | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "Dougie", | ||
"question": "Did you see all them turtles?", | ||
"answer": "They went all the way down!" | ||
"name": "Dougie", | ||
"question": "Did you see all them turtles?", | ||
"answer": "They went all the way down!" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
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 @@ | ||
|
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,31 @@ | ||
package datamodel | ||
|
||
import ( | ||
"github.com/hofstadter-io/hof/schema/dm/sql" | ||
"github.com/hofstadter-io/hof/schema/dm/fields" | ||
) | ||
|
||
// Traditional database model which maps onto tables & columns. | ||
Datamodel: sql.Datamodel & { | ||
Models: { | ||
User: { | ||
Fields: { | ||
ID: fields.UUID | ||
CreatedAt: fields.Datetime | ||
UpdatedAt: fields.Datetime | ||
DeletedAt: fields.Datetime | ||
|
||
email: fields.Email | ||
username: fields.String | ||
password: fields.Password | ||
verified: fields.Bool | ||
active: fields.Bool | ||
|
||
persona: fields.Enum & { | ||
Vals: ["guest", "user", "admin", "owner"] | ||
Default: "user" | ||
} | ||
} | ||
} | ||
} | ||
} |
236 changes: 236 additions & 0 deletions
236
docs/code/getting-started/data-layer/create/hof-eval.cue
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,236 @@ | ||
// Traditional database model which maps onto tables & columns. | ||
Datamodel: { | ||
// schema for #hof: ... | ||
#hof: { | ||
// #hof version | ||
apiVersion: "v1beta1" | ||
|
||
// typical metadata | ||
metadata: {} | ||
|
||
// hof/datamodel | ||
datamodel: { | ||
// define the root of a datamodel | ||
root: true | ||
|
||
// instruct history to be tracked | ||
history: true | ||
|
||
// instruct ordrered version of the fields | ||
// to be injected as a peer value | ||
ordered: false | ||
|
||
// tell hof this is a node of interest for | ||
// the inspection commands (list,info) | ||
node: false | ||
|
||
// tell hof to track this as a raw CUE value | ||
// (partially implemented) | ||
cue: false | ||
} | ||
} | ||
Snapshot: { | ||
Timestamp: "" | ||
} | ||
|
||
// these are the models for the application | ||
// they can map onto database tables and apis | ||
Models: { | ||
User: { | ||
// for easy access | ||
Name: "User" | ||
Plural: "Users" | ||
|
||
// These are the fields of a model | ||
// they can map onto database columnts and form fields | ||
Fields: { | ||
ID: { | ||
Name: "ID" | ||
Plural: "IDs" | ||
Type: "uuid" | ||
Nullable: false | ||
Unique: true | ||
Validation: { | ||
Format: "uuid" | ||
} | ||
#hof: { | ||
metadata: { | ||
name: "ID" | ||
} | ||
} | ||
} | ||
CreatedAt: { | ||
Name: "CreatedAt" | ||
Plural: "CreatedAts" | ||
Type: "datetime" | ||
#hof: { | ||
metadata: { | ||
name: "CreatedAt" | ||
} | ||
} | ||
} | ||
UpdatedAt: { | ||
Name: "UpdatedAt" | ||
Plural: "UpdatedAts" | ||
Type: "datetime" | ||
#hof: { | ||
metadata: { | ||
name: "UpdatedAt" | ||
} | ||
} | ||
} | ||
DeletedAt: { | ||
Name: "DeletedAt" | ||
Plural: "DeletedAts" | ||
Type: "datetime" | ||
#hof: { | ||
metadata: { | ||
name: "DeletedAt" | ||
} | ||
} | ||
} | ||
email: { | ||
Name: "email" | ||
Plural: "emails" | ||
Type: "string" | ||
Length: 64 | ||
Unique: true | ||
Nullable: false | ||
Validation: { | ||
Max: 64 | ||
Format: "email" | ||
} | ||
#hof: { | ||
metadata: { | ||
name: "email" | ||
} | ||
} | ||
} | ||
username: { | ||
Name: "username" | ||
Plural: "usernames" | ||
Type: "string" | ||
Length: 64 | ||
Unique: false | ||
Nullable: false | ||
Validation: { | ||
Max: 64 | ||
} | ||
#hof: { | ||
metadata: { | ||
name: "username" | ||
} | ||
} | ||
} | ||
password: { | ||
Name: "password" | ||
Plural: "passwords" | ||
Bcrypt: true | ||
Type: "string" | ||
Length: 64 | ||
Unique: false | ||
Nullable: false | ||
Validation: { | ||
Max: 64 | ||
} | ||
#hof: { | ||
metadata: { | ||
name: "password" | ||
} | ||
} | ||
} | ||
verified: { | ||
Name: "verified" | ||
Plural: "verifieds" | ||
Type: "bool" | ||
Default: "false" | ||
Nullable: false | ||
#hof: { | ||
metadata: { | ||
name: "verified" | ||
} | ||
} | ||
} | ||
active: { | ||
Name: "active" | ||
Plural: "actives" | ||
Type: "bool" | ||
Default: "false" | ||
Nullable: false | ||
#hof: { | ||
metadata: { | ||
name: "active" | ||
} | ||
} | ||
} | ||
persona: { | ||
Name: "persona" | ||
Plural: "personas" | ||
Type: "string" | ||
Vals: ["guest", "user", "admin", "owner"] | ||
Nullable: false | ||
Default: "user" | ||
#hof: { | ||
metadata: { | ||
name: "persona" | ||
} | ||
} | ||
} | ||
#hof: { | ||
datamodel: { | ||
node: true | ||
ordered: true | ||
} | ||
} | ||
} | ||
|
||
// if we want Relations as a separate value | ||
// we can process the fields to extract them | ||
// schema for #hof: ... | ||
#hof: { | ||
// #hof version | ||
apiVersion: "v1beta1" | ||
|
||
// typical metadata | ||
metadata: { | ||
name: "User" | ||
} | ||
|
||
// hof/datamodel | ||
datamodel: { | ||
// define the root of a datamodel | ||
root: false | ||
|
||
// instruct history to be tracked | ||
history: true | ||
|
||
// instruct ordrered version of the fields | ||
// to be injected as a peer value | ||
ordered: false | ||
|
||
// tell hof this is a node of interest for | ||
// the inspection commands (list,info) | ||
node: false | ||
|
||
// tell hof to track this as a raw CUE value | ||
// (partially implemented) | ||
cue: false | ||
} | ||
} | ||
Snapshot: { | ||
Timestamp: "" | ||
} | ||
History: [] | ||
} | ||
#hof: { | ||
datamodel: { | ||
node: true | ||
ordered: true | ||
} | ||
} | ||
} | ||
|
||
// OrderedModels: [...Model] will be | ||
// inject here for order stability | ||
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,57 @@ | ||
package datamodel | ||
|
||
import ( | ||
"github.com/hofstadter-io/hof/schema/dm/sql" | ||
"github.com/hofstadter-io/hof/schema/dm/fields" | ||
) | ||
|
||
// Traditional database model which maps onto tables & columns. | ||
Datamodel: sql.Datamodel & { | ||
Models: { | ||
User: { | ||
Fields: { | ||
ID: fields.UUID | ||
CreatedAt: fields.Datetime | ||
UpdatedAt: fields.Datetime | ||
DeletedAt: fields.Datetime | ||
|
||
email: fields.Email | ||
username: fields.String | ||
password: fields.Password | ||
verified: fields.Bool | ||
active: fields.Bool | ||
|
||
persona: fields.Enum & { | ||
Vals: ["guest", "user", "admin", "owner"] | ||
Default: "user" | ||
} | ||
|
||
// relation fields | ||
Profile: fields.UUID | ||
Profile: Relation: { | ||
Name: "Profile" | ||
Type: "has-one" | ||
Other: "Models.UserProfile" | ||
} | ||
} | ||
} | ||
|
||
UserProfile: { | ||
Fields: { | ||
// note how we are using sql fields here | ||
sql.CommonFields | ||
|
||
About: sql.Varchar | ||
Avatar: sql.Varchar | ||
Social: sql.Varchar | ||
|
||
Owner: fields.UUID | ||
Owner: Relation: { | ||
Name: "Owner" | ||
Type: "belongs-to" | ||
Other: "Models.User" | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.