purescript-selda icon indicating copy to clipboard operation
purescript-selda copied to clipboard

Easier logging of the update, insert ...

Open jim108dev opened this issue 5 years ago • 0 comments

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".

jim108dev avatar Feb 06 '21 23:02 jim108dev