Update cn doc (#895)

update cn doc for PR #885
This commit is contained in:
JIN 2023-09-03 21:34:19 +08:00 committed by GitHub
parent a3613ee836
commit a5a1d95b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -218,6 +218,21 @@ database.schema("planets").delete()
!!! warning "警告"
外键操作仅发生在数据库中,绕过 Fluent。这意味着模型中间件和软删除之类的东西可能无法正常工作。
## SQL
`.sql` 参数允许你向 schema 中添加任意的 SQL。这对于添加特定的约束或数据类型非常有用。
一个常见的用例是为字段定义默认值:
```swift
.field("active", .bool, .required, .sql(.default(true)))
```
甚至可以为时间戳字段定义默认值:
```swift
.field("created_at", .datetime, .required, .sql(.default(SQLFunction("now"))))
```
## 字典(Dictionary)
字典数据类型能够存储嵌套的字典值。这包括遵循 `Codable` 协议的结构和具有 `Codable` 值的 Swift 字典。