| 1 | import time |
| 2 | import db.sqlite |
| 3 | |
| 4 | @[table: 'task_metadata'] |
| 5 | struct TaskMetadata { |
| 6 | id string @[primary] |
| 7 | task_id string |
| 8 | key string |
| 9 | value string |
| 10 | created_at time.Time @[default: 'CURRENT_TIME'] |
| 11 | updated_at time.Time @[default: 'CURRENT_TIME'] |
| 12 | } |
| 13 | |
| 14 | @[table: 'tasks'] |
| 15 | struct Task { |
| 16 | id string @[primary] |
| 17 | name string |
| 18 | metadata []TaskMetadata @[fkey: 'task_id'] |
| 19 | } |
| 20 | |
| 21 | struct MyService { |
| 22 | mut: |
| 23 | db sqlite.DB |
| 24 | } |
| 25 | |
| 26 | pub fn (s MyService) create(record Task) int { |
| 27 | result := sql s.db { |
| 28 | insert record into Task |
| 29 | } or { return -1 } |
| 30 | return result |
| 31 | } |
| 32 | |
| 33 | fn test_main() { |
| 34 | assert true |
| 35 | } |
| 36 |