diff --git a/flake.lock b/flake.lock index 6dfc9924..80f1c52b 100644 --- a/flake.lock +++ b/flake.lock @@ -370,11 +370,11 @@ "tinylog": "tinylog" }, "locked": { - "lastModified": 1732689486, - "narHash": "sha256-geIUi3MO2l91Ww3lPwztyVdt3gYf4bvqUKopQYfeXxU=", + "lastModified": 1733209116, + "narHash": "sha256-SBNA5q16n4L3H8wTs6i9aSjSKUamWdPWp2bOXBZobE4=", "owner": "nammayatri", "repo": "euler-hs", - "rev": "1d1f4490d5188d0fc07111d4a9be9e8bcb7dfc32", + "rev": "896a634222967245f6eb18ef8439aa324cd88ff4", "type": "github" }, "original": { diff --git a/lib/mobility-core/src/Kernel/Beam/Functions.hs b/lib/mobility-core/src/Kernel/Beam/Functions.hs index 0f0efa58..7ef6ef3b 100644 --- a/lib/mobility-core/src/Kernel/Beam/Functions.hs +++ b/lib/mobility-core/src/Kernel/Beam/Functions.hs @@ -29,6 +29,7 @@ module Kernel.Beam.Functions findAllWithKVAndConditionalDB, findOneWithKVRedis, logQueryData, + findAllFromKvRedis, ) where @@ -317,6 +318,26 @@ findAllWithKVAndConditionalDB where' orderBy = do pure $ catMaybes res' Left err -> throwError $ InternalError $ show err +findAllFromKvRedis :: + forall table m r a. + ( BeamTableFlow table m, + CacheFlow m r, + EsqDBFlow m r, + FromTType' (table Identity) a + ) => + Where Postgres table -> + Maybe (OrderBy table) -> + m [a] +findAllFromKvRedis where' orderBy = do + updatedMeshConfig <- setMeshConfig (modelTableName @table) (modelSchemaName @table) meshConfig + dbConf' <- getReadDBConfigInternal (modelTableName @table) + result <- KV.findAllFromKvRedis dbConf' updatedMeshConfig where' orderBy + case result of + Right res -> do + res' <- mapM fromTType' res + pure $ catMaybes res' + Left err -> throwError $ InternalError $ show err + -- findAllWithOptions -- findAllWithOptionsKV ::