You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/models/introduction.md
+27-3Lines changed: 27 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -168,8 +168,33 @@ If you are not using the `snake_case` convention in your database, then you can
168
168
You can also define the database column names explicitly within the `@column` decorator. This is usually helpful for bypassing the convention in specific use cases.
Lucid allows you to transform the column values before saving them to the database or after fetching them from the database using the `consume` and `prepare` option.
182
+
183
+
For example, you are storing a "secret" value in the database, and you want to encrypt it before saving it and decrypt it after fetching it.
184
+
185
+
```ts
186
+
// In this example, we are using the `encryption` module from the `@adonisjs/core` package
@@ -196,7 +221,6 @@ export default class User extends BaseModel {
196
221
197
222
Optionally, you can pass the `autoCreate` and `autoUpdate` options to always define the timestamps during the creation and the update operations. **Do note, setting these options doesn't modify the database table or its triggers.**
198
223
199
-
200
224
## Models config
201
225
202
226
Following are the configuration options to overwrite the conventional defaults.
0 commit comments