parent
d9864bd9ff
commit
92c985667f
2 changed files with 6 additions and 8 deletions
|
@ -11,7 +11,7 @@ import ids/cuid
|
|||
import wisp.{type Request, type Response}
|
||||
|
||||
const schema = "
|
||||
CREATE TABLE IF NOT EXISTS \"file\" (
|
||||
CREATE TABLE IF NOT EXISTS file (
|
||||
cuid CHAR(25) PRIMARY KEY,
|
||||
md5hash CHAR(32),
|
||||
fileName TEXT
|
||||
|
@ -28,8 +28,7 @@ pub fn prepare_database(ctx: Context) -> Result(Nil, pgo.QueryError) {
|
|||
}
|
||||
|
||||
pub fn store(file: File, ctx: Context) -> Result(String, Nil) {
|
||||
let sql =
|
||||
"INSERT INTO \"file\" (cuid, md5hash) VALUES ($1, $2) RETURNING cuid;"
|
||||
let sql = "INSERT INTO file (cuid, md5hash) VALUES ($1, $2) RETURNING cuid;"
|
||||
case
|
||||
pgo.execute(
|
||||
sql,
|
||||
|
@ -45,7 +44,7 @@ pub fn store(file: File, ctx: Context) -> Result(String, Nil) {
|
|||
}
|
||||
|
||||
pub fn retrieve(cuid: String, ctx: Context) -> Result(File, Nil) {
|
||||
let sql = "SELECT cuid,md5hash,filename FROM \"file\" WHERE cuid = $1;"
|
||||
let sql = "SELECT cuid,md5hash,filename FROM file WHERE cuid = $1;"
|
||||
case
|
||||
pgo.execute(
|
||||
sql,
|
||||
|
|
|
@ -10,7 +10,7 @@ import ids/cuid
|
|||
import wisp.{type Request, type Response}
|
||||
|
||||
const schema = "
|
||||
CREATE TABLE IF NOT EXISTS \"link\" (
|
||||
CREATE TABLE IF NOT EXISTS link (
|
||||
cuid CHAR(25) PRIMARY KEY,
|
||||
targeturl TEXT
|
||||
);
|
||||
|
@ -26,8 +26,7 @@ pub fn prepare_database(ctx: Context) -> Result(Nil, pgo.QueryError) {
|
|||
}
|
||||
|
||||
pub fn store(link: Link, ctx: Context) -> Result(String, Nil) {
|
||||
let sql =
|
||||
"INSERT INTO \"link\" (cuid, targeturl) VALUES ($1, $2) RETURNING cuid;"
|
||||
let sql = "INSERT INTO link (cuid, targeturl) VALUES ($1, $2) RETURNING cuid;"
|
||||
case
|
||||
pgo.execute(
|
||||
sql,
|
||||
|
@ -43,7 +42,7 @@ pub fn store(link: Link, ctx: Context) -> Result(String, Nil) {
|
|||
}
|
||||
|
||||
pub fn retrieve(cuid: String, ctx: Context) -> Result(Link, Nil) {
|
||||
let sql = "SELECT cuid,targeturl FROM \"link\" WHERE cuid = $1;"
|
||||
let sql = "SELECT cuid,targeturl FROM link WHERE cuid = $1;"
|
||||
case
|
||||
pgo.execute(
|
||||
sql,
|
||||
|
|
Loading…
Add table
Reference in a new issue