-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import time | ||
import db.sqlite | ||
|
||
@[table: 'task_metadata'] | ||
struct TaskMetadata { | ||
id string @[primary] | ||
task_id string | ||
key string | ||
value string | ||
created_at time.Time @[default: 'CURRENT_TIME'] | ||
updated_at time.Time @[default: 'CURRENT_TIME'] | ||
} | ||
|
||
@[table: 'tasks'] | ||
struct Task { | ||
id string @[primary] | ||
name string | ||
metadata []TaskMetadata @[fkey: 'task_id'] | ||
} | ||
|
||
struct MyService { | ||
mut: | ||
db sqlite.DB | ||
} | ||
|
||
pub fn (s MyService) create(record Task) int { | ||
result := sql s.db { | ||
insert record into Task | ||
} or { return -1 } | ||
return result | ||
} | ||
|
||
fn test_main() { | ||
assert true | ||
} |