v2 / vlib / v / tests / orm_array_field_test.v
35 lines · 30 sloc · 596 bytes · ebb3a8eb253921e51610adf3028f83f5eddd934d
Raw
1import time
2import db.sqlite
3
4@[table: 'task_metadata']
5struct 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']
15struct Task {
16 id string @[primary]
17 name string
18 metadata []TaskMetadata @[fkey: 'task_id']
19}
20
21struct MyService {
22mut:
23 db sqlite.DB
24}
25
26pub 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
33fn test_main() {
34 assert true
35}
36