Skip to content

Commit 331d87a

Browse files
authored
chore: add @password @omit field attributes documentation (#47)
1 parent 5c813e3 commit 331d87a

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

docs/get-started/learning-the-zmodel-language.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,39 @@ model Post {
8989
}
9090
```
9191

92-
Please refer to [Prisma's documentation](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#attributes) for an exhaustive list of attributes and functions.
92+
ZenStack inherits most attributes and functions from Prisma, and added a number of new ones:
93+
94+
- `@password`
95+
96+
A field attribute that marks a field as a password. Before storing such a field, ZenStack hashes its value with [bcryptjs](https://github.com/dcodeIO/bcrypt.js), with a default salt length of 12.
97+
98+
You can override the default setting with the `saltLength` or `salt` named parameters, like:
99+
100+
```prisma
101+
model User {
102+
password String @password(saltLength: 16)
103+
}
104+
105+
model User {
106+
password String @password(salt: "mysalt")
107+
}
108+
```
109+
110+
If both `saltLength` and `salt` parameters are provided, `salt` is used.
111+
112+
- `@omit`
113+
114+
A field attribute that marks a field to be excluded when model entities are read from the generated service. This is often used to prevent sensitive information from being returned to the front-end code (e.g., password, even hashed).
115+
116+
E.g.:
117+
118+
```prisma
119+
model User {
120+
password String @password @omit
121+
}
122+
```
123+
124+
For attributes and functions inherited from Prisma, please refer to [Prisma's documentation](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#attributes) for details.
93125

94126
## Relations
95127

0 commit comments

Comments
 (0)