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
+20-19Lines changed: 20 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -152,6 +152,26 @@ The `@column` decorator additionally accepts options to configure the property b
152
152
- The `isPrimary` option marks the property as the primary key for the given database table.
153
153
- The `serializeAs: null` option removes the property when you serialize the model to JSON.
154
154
155
+
### Column names
156
+
157
+
Lucid assumes that your database columns names are defined as `snake_case` and automatically converts the model properties to snake case during database queries. For example:
158
+
159
+
```ts
160
+
awaitUser.create({ avatarUrl: 'foo.jpg' })
161
+
162
+
// EXECUTED QUERY
163
+
// insert into "users" ("avatar_url") values (?)
164
+
```
165
+
166
+
If you are not using the `snake_case` convention in your database, then you can override the default behavior of Lucid by defining a custom [Naming Strategy](./naming_strategy.md)
167
+
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 further enhances the date and the date-time properties and converts the database driver values to an instance of [luxon.DateTime](https://moment.github.io/luxon/).
@@ -176,25 +196,6 @@ export default class User extends BaseModel {
176
196
177
197
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.**
178
198
179
-
### Column names
180
-
181
-
Lucid assumes that your database columns names are defined as `snake_case` and automatically converts the model properties to snake case during database queries. For example:
182
-
183
-
```ts
184
-
awaitUser.create({ avatarUrl: 'foo.jpg' })
185
-
186
-
// EXECUTED QUERY
187
-
// insert into "users" ("avatar_url") values (?)
188
-
```
189
-
190
-
If you are not using the `snake_case` convention in your database, then you can override the default behavior of Lucid by defining a custom [Naming Strategy](./naming_strategy.md)
191
-
192
-
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.
0 commit comments