Skip to content

Commit

Permalink
Merge pull request #82 from hofstadter-io/prototype-dm
Browse files Browse the repository at this point in the history
Implement `hof/datamodel` command
  • Loading branch information
verdverm authored Jan 13, 2022
2 parents 2606792 + 2c9134c commit a6d20a5
Show file tree
Hide file tree
Showing 71 changed files with 2,056 additions and 806 deletions.
51 changes: 51 additions & 0 deletions .hof/dm/MyModels/20211230215508.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ver_20211230215508: {
@datamodel(), @dm_ver(0.0.1)
Name: "MyModels"

// Models in the data model, ordered
Models: {
User: {
@dm_model()
Name: "User"
Fields: {
// sql.#CommonFields
email: {
@dm_field()
Name: "email"
Type: "string"
Length: 64
Unique: true
Nullable: false
Validation: {
Max: 64
Format: "email"
}
}
//persona: fields.#Enum & {
//vals: ["guest", "user", "admin", "owner"]
//default: "guest"
//}
password: {
@dm_field()
Name: "password"
Bcrypt: true
Type: "string"
Length: 64
Unique: false
Nullable: false
Validation: {
Max: 64
}
}
active: {
@dm_field()
Name: "active"
Type: "bool"
Default: "false"
Nullable: false
}
}
}
// "UserProfile": UserProfile
}
}
90 changes: 90 additions & 0 deletions .hof/dm/MyModels/20211230215604.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
ver_20211230215604: {
@datamodel(), @dm_ver(0.0.2)
Name: "MyModels"

// Models in the data model, ordered
Models: {
User: {
@dm_model()
Name: "User"
Fields: {
// sql.#CommonFields
email: {
@dm_field()
Name: "email"
Type: "string"
Length: 64
Unique: true
Nullable: false
Validation: {
Max: 64
Format: "email"
}
}
//persona: fields.#Enum & {
//vals: ["guest", "user", "admin", "owner"]
//default: "guest"
//}
password: {
@dm_field()
Name: "password"
Bcrypt: true
Type: "string"
Length: 64
Unique: false
Nullable: false
Validation: {
Max: 64
}
}
active: {
@dm_field()
Name: "active"
Type: "bool"
Default: "false"
Nullable: false
}
}
}
UserProfile: {
@dm_model()
Name: "UserProfile"
Fields: {
// sql.#CommonFields
firstName: {
@dm_field()
Name: "firstName"
Type: "string"
Length: 64
Unique: false
Nullable: false
Validation: {
Max: 64
}
}
middleName: {
@dm_field()
Name: "middleName"
Type: "string"
Length: 64
Unique: false
Nullable: false
Validation: {
Max: 64
}
}
lastName: {
@dm_field()
Name: "lastName"
Type: "string"
Length: 64
Unique: false
Nullable: false
Validation: {
Max: 64
}
}
}
}
}
}
154 changes: 154 additions & 0 deletions .hof/dm/MyModels/20211230215655.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
ver_20211230215655: {
@datamodel(), @dm_ver(0.0.3)
Name: "MyModels"

// Models in the data model, ordered
Models: {
User: {
@dm_model()
Name: "User"
Fields: {
email: {
@dm_field()
Name: "email"
Type: "string"
Length: 64
Unique: true
Nullable: false
Validation: {
Max: 64
Format: "email"
}
}
//persona: fields.#Enum & {
//vals: ["guest", "user", "admin", "owner"]
//default: "guest"
//}
password: {
@dm_field()
Name: "password"
Bcrypt: true
Type: "string"
Length: 64
Unique: false
Nullable: false
Validation: {
Max: 64
}
}
ID: {
@dm_field()
Name: "ID"
Type: "uuid"
Nullable: false
Unique: true
Default: "gen_random_uuid()"
Validation: {
Format: "uuid"
}
}
CID: {
@dm_field()
Name: "CID"
Type: "cuid"
Nullable: false
Unique: true
}
CreatedAt: {
@dm_field()
Name: "CreatedAt"
Type: "datetime"
}
UpdatedAt: {
@dm_field()
Name: "UpdatedAt"
Type: "datetime"
}
active: {
@dm_field()
Name: "active"
Type: "bool"
Default: "false"
Nullable: false
}
DeletedAt: {
@dm_field()
Name: "DeletedAt"
Type: "datetime"
}
}
}
UserProfile: {
@dm_model()
Name: "UserProfile"
Fields: {
firstName: {
@dm_field()
Name: "firstName"
Type: "string"
Length: 64
Unique: false
Nullable: false
Validation: {
Max: 64
}
}
middleName: {
@dm_field()
Name: "middleName"
Type: "string"
Length: 64
Unique: false
Nullable: false
Validation: {
Max: 64
}
}
ID: {
@dm_field()
Name: "ID"
Type: "uuid"
Nullable: false
Unique: true
Default: "gen_random_uuid()"
Validation: {
Format: "uuid"
}
}
CID: {
@dm_field()
Name: "CID"
Type: "cuid"
Nullable: false
Unique: true
}
CreatedAt: {
@dm_field()
Name: "CreatedAt"
Type: "datetime"
}
UpdatedAt: {
@dm_field()
Name: "UpdatedAt"
Type: "datetime"
}
lastName: {
@dm_field()
Name: "lastName"
Type: "string"
Length: 64
Unique: false
Nullable: false
Validation: {
Max: 64
}
}
DeletedAt: {
@dm_field()
Name: "DeletedAt"
Type: "datetime"
}
}
}
}
}
Loading

0 comments on commit a6d20a5

Please sign in to comment.