blob: eee21415641800850e0bebbc0ca41dc4c8785d8c (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#lang typed/racket
(require typed/db)
(module untyped-db-ops racket
(require db
db/util/datetime
"../entities/article.rkt")
(provide fetch-tag-ids
insert-tag)
(define (fetch-tag-ids conn)
(for/hash ([(name tag-id)
(in-query conn "SELECT name, tag_id FROM diary.tags")])
(values name tag-id)))
(define (insert-tag conn name)
(query-value conn
"
INSERT INTO diary.tags(name)
VALUES($1)
RETURNING tag_id
"
name)))
(require/typed/provide (submod "." untyped-db-ops)
[fetch-tag-ids (-> Connection (Immutable-HashTable String Integer))]
[insert-tag (-> Connection String Integer)])
|