orm: fix the old attribute syntax in the README's example, to the new @[attr] form (#20305)

This commit is contained in:
xjzh123 2023-12-30 01:00:37 +08:00 committed by GitHub
parent 7fc31591ad
commit 7b04476683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,16 +32,16 @@ import time
@[table: 'foos']
struct Foo {
id int [primary; sql: serial]
id int @[primary; sql: serial]
name string
created_at time.Time [default: 'CURRENT_TIME]
updated_at ?string [sql_type: 'TIMESTAMP]
created_at time.Time @[default: 'CURRENT_TIME']
updated_at ?string @[sql_type: 'TIMESTAMP']
deleted_at ?time.Time
children []Child [fkey: 'parent_id']
children []Child @[fkey: 'parent_id']
}
struct Child {
id int [primary; sql: serial]
id int @[primary; sql: serial]
parent_id int
name string
}
@ -131,9 +131,9 @@ result := sql db {
import db.pg
struct Member {
id string [default: 'gen_random_uuid()'; primary; sql_type: 'uuid']
id string @[default: 'gen_random_uuid()'; primary; sql_type: 'uuid']
name string
created_at string [default: 'CURRENT_TIMESTAMP'; sql_type: 'TIMESTAMP']
created_at string @[default: 'CURRENT_TIMESTAMP'; sql_type: 'TIMESTAMP']
}
fn main() {