module Store.Query.Type ( module Store.Query.Field, module Store.Query.Record, Collection, Comparison (..), EmbedClause (..), EmbedClauses, FieldSelector (..), JoinClause (..), JoinClauses, JoinType (..), Query (..), WhereClause (..), LimitClause (..), OffsetClause (..), ) where import Data.Aeson qualified as J import Data.Map qualified as M import Store.Query.Field import Store.Query.Record data Query = Delete Collection (Maybe WhereClause) | Insert [J.Value] Collection | Select FieldSelector Collection (JoinClauses FilePath) (EmbedClauses FilePath) (Maybe WhereClause) (Maybe LimitClause) (Maybe OffsetClause) | Update Collection J.Value (Maybe WhereClause) data FieldSelector = SelectObject (M.Map String FieldSelector) | SelectField Field deriving (Show) type Collection = FilePath type JoinClauses a = [JoinClause a] data JoinClause a = JoinClause JoinType a (Maybe WhereClause) deriving (Show) data JoinType = JoinLeft | JoinRight | JoinFull deriving (Show) type EmbedClauses a = [EmbedClause a] data EmbedClause a = EmbedClause a (Maybe WhereClause) deriving (Show) data WhereClause = And [WhereClause] | Or [WhereClause] | Where Comparison deriving (Show) data Comparison = Eq (Either J.Value Field) (Either J.Value Field) deriving (Show) data LimitClause = Limit Int deriving (Show) data OffsetClause = Offset Int deriving (Show)