diff --git a/gren.json b/gren.json index e2b586a..2a64fa2 100644 --- a/gren.json +++ b/gren.json @@ -8,7 +8,7 @@ "dependencies": { "direct": { "blaix/gren-effectful-tests": "6.0.0", - "blaix/gren-ws4sql": "3.0.2", + "blaix/gren-ws4sql": "4.0.0", "gren-lang/core": "7.0.0", "gren-lang/node": "6.0.0", "gren-lang/test": "5.0.0", @@ -18,4 +18,4 @@ "gren-lang/test-runner-node": "7.0.0" } } -} \ No newline at end of file +} diff --git a/gren_packages/blaix_gren_ws4sql__3_0_2.pkg.gz b/gren_packages/blaix_gren_ws4sql__3_0_2.pkg.gz deleted file mode 100644 index 52349a7..0000000 Binary files a/gren_packages/blaix_gren_ws4sql__3_0_2.pkg.gz and /dev/null differ diff --git a/gren_packages/blaix_gren_ws4sql__4_0_0.pkg.gz b/gren_packages/blaix_gren_ws4sql__4_0_0.pkg.gz new file mode 100644 index 0000000..8e67c51 Binary files /dev/null and b/gren_packages/blaix_gren_ws4sql__4_0_0.pkg.gz differ diff --git a/src/PublishingIdentity.gren b/src/PublishingIdentity.gren index da1cc31..224aff2 100644 --- a/src/PublishingIdentity.gren +++ b/src/PublishingIdentity.gren @@ -96,15 +96,12 @@ get db { userId, name } = , Encode.string "name" name ] , decoder = - -- TODO: upgrade gren-ws4sql for the new api here - Decode.get3 - (Decode.int "id") - (Decode.int "user_id") - (Decode.string "name") - (\id uid n -> + Decode.field Decode.int "id" <| \id -> + Decode.field Decode.int "user_id" <| \uid -> + Decode.field Decode.string "name" <| \n -> + Decode.succeed { id = id , userId = uid , name = n } - ) } diff --git a/src/User.gren b/src/User.gren index 60c63a3..d411297 100644 --- a/src/User.gren +++ b/src/User.gren @@ -23,24 +23,19 @@ type alias User = decoder : Decoder User decoder = - Decode.string "email" - |> Decode.andThen - (\email -> - when (Email.fromString email) is - Nothing -> - Decode.fail ("Invalid email: " ++ email) - - Just e -> - Decode.get2 - (Decode.int "id") - (Decode.posix "created") - (\id created -> - { id = id - , created = created - , email = e - } - ) - ) + Decode.field Decode.string "email" <| \email -> + when (Email.fromString email) is + Nothing -> + Decode.fail ("Invalid email: " ++ email) + + Just e -> + Decode.field Decode.int "id" <| \id -> + Decode.field Decode.posix "created" <| \created -> + Decode.succeed + { id = id + , created = created + , email = e + } findBySessionToken : Db.Connection -> String -> Task Db.Error User