usando idiorm em lisp com pharen

macros

(defmacro orm-config (type host db username password) 
'(do
(:: ORM (configure (. ~type ":host=" ~host ";dbname=" ~db )))

(:: ORM (configure "username" ~username))

(:: ORM (configure "password" ~password))

)

)


(micro table-for (tbl) (:: ORM (for_table ~tbl)))


(defmacro orm-select (tbl fields where order)

'
(-> (table-for ~tbl) (select ~fields) (where ~where) (order ~order) (find-many)))

exemplo

(orm-config #mysql #127.0.0.1 #db_my #root #root)

(-> (table-for #users)
(where #id 5)
(find_one)
)

(orm-select #users "name,surname" (. "id=" 2) "id desc")