feat: isReferenced

This commit is contained in:
bingus 2023-12-18 09:04:55 -06:00
parent 2eba8bd07f
commit 30fff94a26
Signed by: orion
GPG Key ID: 6D4165AE4C928719
2 changed files with 8 additions and 1 deletions

View File

@ -10,6 +10,7 @@ package:
- effect
- either
- exceptions
- foldable-traversable
- foreign
- fork
- maybe

View File

@ -2,8 +2,9 @@ module Data.Postgres.Query.Builder where
import Prelude
import Control.Monad.State (StateT, modify, runStateT)
import Control.Monad.State (StateT, get, modify, runStateT)
import Data.Array as Array
import Data.Foldable (any, elem)
import Data.Set (Set)
import Data.Set as Set
import Data.Tuple.Nested (type (/\))
@ -18,6 +19,11 @@ runBuilder = flip runStateT { params: [], refs: Set.empty }
reference :: forall m. Monad m => String -> BuilderT m Unit
reference k = void $ modify (\s@{ refs } -> s { refs = Set.insert k refs })
isReferenced :: forall m. Monad m => Array String -> BuilderT m Boolean
isReferenced ts = do
{ refs } <- get
pure $ any (flip elem ts) refs
param :: forall m a. Monad m => ToSQLValue a => a -> BuilderT m String
param p =
do