Skip to content

chore: add @password @omit field attributes documentation #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion docs/get-started/learning-the-zmodel-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,39 @@ model Post {
}
```

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.
ZenStack inherits most attributes and functions from Prisma, and added a number of new ones:

- `@password`

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.

You can override the default setting with the `saltLength` or `salt` named parameters, like:

```prisma
model User {
password String @password(saltLength: 16)
}

model User {
password String @password(salt: "mysalt")
}
```

If both `saltLength` and `salt` parameters are provided, `salt` is used.

- `@omit`

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).

E.g.:

```prisma
model User {
password String @password @omit
}
```

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.

## Relations

Expand Down