aboutsummaryrefslogtreecommitdiffstats
path: root/src/Store/Query/Record.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Store/Query/Record.hs')
-rw-r--r--src/Store/Query/Record.hs20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/Store/Query/Record.hs b/src/Store/Query/Record.hs
index 71461d5..b00be27 100644
--- a/src/Store/Query/Record.hs
+++ b/src/Store/Query/Record.hs
@@ -5,7 +5,6 @@ module Store.Query.Record
lookup,
Records,
lookups,
- select,
disjointUnion,
disjointUnions,
)
@@ -16,8 +15,7 @@ import Data.Aeson qualified as J
import Data.Aeson.Key qualified as JK
import Data.Aeson.KeyMap qualified as JM
import Data.List (foldl')
-import Data.List.NonEmpty qualified as N
-import Data.Maybe (fromMaybe, mapMaybe)
+import Data.Maybe (mapMaybe)
import Data.Text qualified as T
import Store.Exception (DuplicateField (DuplicateField))
import Store.Query.Field
@@ -36,10 +34,8 @@ toValue :: Record a -> a
toValue (Record _ v) = v
lookup :: Field -> Record J.Value -> Maybe J.Value
-lookup (Unqualified ks) (Record _ v) =
- lookup' (N.toList ks) v
-lookup (Qualified c' ks) (Record c v)
- | c' == c = lookup' (N.toList ks) v
+lookup (Field c' ks) (Record c v)
+ | c' == c = lookup' ks v
| otherwise = Nothing
lookup' :: [T.Text] -> J.Value -> Maybe J.Value
@@ -56,16 +52,6 @@ lookups f rs =
[v] -> Just v
(_ : _) -> throw (DuplicateField (toString f))
-select :: [Field] -> Records J.Value -> J.Value
-select fs rs =
- foldl'
- union
- (J.Object JM.empty)
- (map (\f -> prefix f ((fromMaybe J.Null (lookups f rs)))) fs)
-
-union :: J.Value -> J.Value -> J.Value
-union (J.Object r) (J.Object s) = J.Object (JM.unionWith union r s)
-
disjointUnion :: J.Value -> J.Value -> J.Value
disjointUnion (J.Object r) (J.Object s) =
J.Object (JM.unionWithKey disjointUnion' r s)