Kamirus / purescript-selda

A type-safe, high-level SQL library for PureScript
MIT License
89 stars 3 forks source link

Easier logging of the update, insert ... #45

Open jim108dev opened 3 years ago

jim108dev commented 3 years ago

I guess everybody who wants to log his or her queries/commands is doing the same,

logUpdate ∷
  forall t s r m.
  TableToColsWithoutAlias s t r =>
  GetCols r =>
  MonadEffect m =>
  Table t → ({ | r } → Col s Boolean) → ({ | r } → { | r }) → m Unit
logUpdate table pred up = do
  let
    { strQuery, params } = showPG $ showUpdate table pred up
  log strQuery
  log $ unsafeStringify params
  log ""

logQuery :: forall s i m. GetCols i => MonadEffect m => FullQuery s { | i } -> m Unit
logQuery q = do
  let
    { strQuery, params } = showPG $ showQuery q
  log strQuery
  log $ unsafeStringify params
  log ""
...

I don't know how to do it, but it would be nice to have some sort of tee or errorTee function, which lets me express the statement "I would like to see the generated output".