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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
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)
|