Skip to content

Instantly share code, notes, and snippets.

@BitPuffin
Created December 9, 2013 14:40
Show Gist options
  • Save BitPuffin/3f02d0488c67d169124c to your computer and use it in GitHub Desktop.
Save BitPuffin/3f02d0488c67d169124c to your computer and use it in GitHub Desktop.
template getFromWhere*(id, row, table: string): expr =
db.getRow(sql"select 1 from ? where ? = ?", table, row, id)
template getFrom*(id, table: string): expr =
getFromWhere(id, "id", table)
proc getUser*(id: string): TRow =
result = id.getFrom("users")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment