[racket] How to insert array into Postgresql using DB module
Thank you.
If I may ask another question, what is the best way to handle
inserting a new record and fetching that ID?
Is there a better way than what I am about to do below?
;; [String] -> ID
(define (create! ... )
(define batch!
(lambda ()
(define prev-id
(query-value conn
"SELECT id FROM tableORDER BY id DESC LIMIT 1"))
(query (my-conn)
"INSERT INTO table (cols ...) VALUES ($1, $2, $3, $4, $5)"
...)
;; return assuming the ID is one greater that prev-id
(+ 1 prev-id)))
(call-with-transaction conn
batch!))