@notiz/prisma-formly-generator v0.7.0
prisma-formly-generator
Installation
npm i -D @notiz/prisma-formly-generator
Add the generator to your schema.prisma
generator formly {
provider = "prisma-formly-generator"
output = "change/output/dir"
}
Prisma decorators
Add comments ///
to model fields including one of the following decorators to change the generated output.
⚙️ Field type and template options
Use @Formly.field({ OPTIONS })
to change the field type and template options for the generated formly field.
The OPTIONS
are
Option | Example |
---|---|
fieldType | color-picker |
label | Email Address |
description | Identify user |
placeholder | hi@example.com |
type | email , password , file |
disabled | true | false |
validators | ['email'] |
min | 3 |
minLength | 3 |
max | 150 |
maxLength | 150 |
rows | 3 |
cols | 3 |
tabindex | 3 |
step | 3 |
model User {
id Int @id @default(autoincrement())
/// @Formly.field({ label: 'Email Address', type: 'email' })
email String @unique
name String?
/// @Formly.field({ fieldType: 'color-picker' })
color String?
}
🕶️ Hide model or field
Use @Formly.hide
or @Formly.hide()
to hide a model or field from the generated output for example for secrets or internal models.
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
/// @Formly.hide()
password String
}
/// @Formly.hide()
model Logs {
id Int @id @default(autoincrement())
logs Json
}
⛔️ Excluded fields
Certain fields are filled on database or Prisma level. Thus, these fields are excluded automatically from being generated.
Description | Field | Example |
---|---|---|
Id field with default value | fieldName Type @id @default(...) | id Int @id @default(autoincrement()) |
DateTime field with default now | fieldName DateTime @default(now()) | createdAt DateTime @default(now()) |
DateTime filed with @updateAt | fieldName DateTime @updateAt | updatedAt DateTime @updatedAt |
Foreign keys of relations | fieldName Model? @relation(fields: [foreignKey], references: [id]) | user User? @relation(fields: [userId], references: [id]) , userId is excluded |
💻 Development
npm i
# generate formly new
npm run prisma:generate
# test out formly
cd ng-formly && npm i && ng s
💡 Ideas
- add groups/layout to builder
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago