-
I initially posted this as an issue, but then realized it's probably better suited here. So I've been trying out Rel8 on a project recently and I was wondering if there's some way to easily map a Say I have this data type that corresponds to a SQL table: data DBUser f =
DBUser
{ dbUserId :: Column f Int64
, dbUserEmail :: Column f Text
, dbUserName :: Column f Text
}
deriving stock (Generic)
deriving anyclass (Rel8able)
usersTable :: TableSchema (DBUser Name)
usersTable =
TableSchema
{ name = "users"
, schema = Nothing
, columns =
DBUser
{ dbUserId = "id"
, dbUserEmail = "email"
, dbUserName = "username"
}
}
queryUsers :: Query (DBUser Expr)
queryUsers =
each usersTable And then I have a similar type from my domain like so: data User =
User
{ userEmail :: Text
, userName :: Text
} What I'm trying to figure out is if there's some sort of type class instance I can add for selectUsers :: Statement () [User]
selectUsers =
select queryUsers I took a look at the For reference, I've used Opaleye a fair bit and there I would achieve something similar by doing this: instance Default QueryRunner (DBUser Expr) User where
def =
(flip rmap) (def :: QueryRunner (DBUser Expr) (DBUser Result)) $
\(DBUser _ email name) -> User email name So I guess I'm just trying to figure out if there's a roughly similar convenience in Rel8. No worries if not! I've really enjoyed working with this library thus far! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There isn't a way to do this with Rel8 at the moment. |
Beta Was this translation helpful? Give feedback.
There isn't a way to do this with Rel8 at the moment.