aboutsummaryrefslogtreecommitdiffstats
path: root/app/Query/Type.hs
blob: d27106fff88068cd5c3c91519733a676cd8bac7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
module Query.Type
  ( module Query.Field,
    module Query.Record,
    Collection,
    Comparison (..),
    EmbedClause (..),
    EmbedClauses,
    FieldSelector (..),
    JoinClause (..),
    JoinClauses,
    JoinType (..),
    Query (..),
    WhereClause (..),
  )
where

import Data.List.NonEmpty qualified as N
import Query.Field
import Query.Record

data Query
  = Select
      FieldSelector
      Collection
      (JoinClauses FilePath)
      (EmbedClauses FilePath)
      (Maybe WhereClause)

data FieldSelector
  = All
  | Only (N.NonEmpty 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 Field Field
  deriving (Show)