[{"name":"Db","comment":" Short for \"Database\", `Db item` is basically a glorified `Dict String item`. It takes `Id item`, and it if has an `item` under that `Id item`, it gives it to you.\n\n    users : Db User\n    users =\n        --\n\n    maybeBob : (Id User, Maybe User)\n    maybeBob =\n        Db.get users (Id.fromString \"bob\")\n\nThe functions in the `Db` module are much like those of `Dict`, but they are specialized for the use case of a relational database.\n\n\n# Db\n\n@docs Db, empty, Row\n\n\n# List\n\n@docs fromList, toList\n\n\n# Insert\n\n@docs insert, insertMany\n\n\n# Get\n\n@docs get, getWithId, getMany\n\n\n# Update\n\n@docs update\n\n\n# Map\n\n@docs map, mapItem\n\n\n# Remove\n\n@docs remove\n\n\n# Filter\n\n@docs filter, filterMissing, allPresent\n\n","unions":[{"name":"Db","comment":" Short for \"Database\", it stores data by unique identifiers\n","args":["item"],"cases":[]}],"aliases":[{"name":"Row","comment":" A single row in the `Db`; an `item` paired with its `Id`\n","args":["item"],"type":"( Id.Id item, item )"}],"values":[{"name":"allPresent","comment":" Verify that all the items are present, and if not, fail with a list of the items that are missing\n\n    allPresent [ (id1, Just user1), (id2, Just user2) ]\n    --> Ok [ (id1, user1), (id2, user2) ]\n\n    allPresent [ (id1, Nothing), (id2, Just user2), (id3, Nothing) ]\n    --> Err [ id1, id3 ]\n\n","type":"List.List ( Id.Id item, Maybe.Maybe item ) -> Result.Result (List.List (Id.Id item)) (List.List (Db.Row item))"},{"name":"empty","comment":" An empty `Db` with no entries\n","type":"Db.Db item"},{"name":"filter","comment":" Filter out items from a `Db`\n","type":"(Db.Row item -> Basics.Bool) -> Db.Db item -> Db.Db item"},{"name":"filterMissing","comment":" Take a `List` of items, presumably ones you just retrieved using `getMany`, and filter out\nthe ones that werent present in the `Db`\n\n    myFriendsList\n        |> Db.getMany people\n        |> Db.filterMissing\n        -->: List (Row Person)\n\n","type":"List.List ( Id.Id item, Maybe.Maybe item ) -> List.List (Db.Row item)"},{"name":"fromList","comment":" Initialize a `Db` from a list of id-value pairs\n","type":"List.List (Db.Row item) -> Db.Db item"},{"name":"get","comment":" Get the item under the provided `Id`\n","type":"Db.Db item -> Id.Id item -> Maybe.Maybe item"},{"name":"getMany","comment":" Get many items from a `Db`. The `(id, Nothing)` case represents the item under that `Id` being absent.\n","type":"Db.Db item -> List.List (Id.Id item) -> List.List ( Id.Id item, Maybe.Maybe item )"},{"name":"getWithId","comment":" Just like `get`, except it comes with the `Id`, for those cases where you dont want the item separated from its `Id`\n","type":"Db.Db item -> Id.Id item -> ( Id.Id item, Maybe.Maybe item )"},{"name":"insert","comment":" Insert an item into the `Db` under the given `Id`\n","type":"Db.Row item -> Db.Db item -> Db.Db item"},{"name":"insertMany","comment":" Insert many items into the `Db` under their given `Id`s\n","type":"List.List (Db.Row item) -> Db.Db item -> Db.Db item"},{"name":"map","comment":" Map a `Db` to a different data type.\n","type":"(a -> b) -> Db.Db a -> Db.Db b"},{"name":"mapItem","comment":" Apply a change to just one item in the `Db`, assuming the item is in the `Db` in the first place. This function is just like `update` except deleting the item is not possible.\n","type":"Id.Id item -> (item -> item) -> Db.Db item -> Db.Db item"},{"name":"remove","comment":" Remove the item at the given `Id`, if it exists\n","type":"Id.Id item -> Db.Db item -> Db.Db item"},{"name":"toList","comment":" Turn your `Db` into a list\n","type":"Db.Db item -> List.List (Db.Row item)"},{"name":"update","comment":" Update an item in a `Db`, using an update function. If the item doesnt exist in the `Db`, it comes into the update as `Nothing`. If a `Nothing` comes out of the update function, the value under that id will be removed.\n","type":"Id.Id item -> (Maybe.Maybe item -> Maybe.Maybe item) -> Db.Db item -> Db.Db item"}],"binops":[]},{"name":"Id","comment":" This package exposes a really simple type called `Id`.\n\n    type Id x\n        = Id String\n\nIts for when your data has an id. Such as..\n\n    import Id exposing (Id)\n\n    type alias User =\n        { id : Id ()\n        , email : String\n        }\n\n\n### Why an `Id` and not a `String`?\n\nThe Elm compiler is totally okay with the following code snippet..\n\n    viewUser : String -> String -> Html Msg\n    viewUser email id =\n        -- first parameter is email\n        -- second parameter is id\n\n\n    view : Model -> Html Msg\n    view model =\n        div\n            []\n            [ viewUser\n                -- woops! The parameters are mixed up\n                model.user.id\n                model.user.email\n            ]\n\nThese mistake is really easy to make and they cause real problems, but if you just use an `Id` you can make them impossible.\n\n\n### Whats the `x` in `Id x` for?\n\nYou understand the problem in the previous example right? Here is a very similar problem..\n\n    type Id\n        = Id String\n\n    updateUsersCatsFavoriteFood : Id -> Id -> Id -> Cmd Msg\n    updateUsersCatsFavoriteFood userId catId foodId =\n        -- ..\n\nTheres absolutely nothing stopping a developer from mixing up a `catId` with a `userId` or a `foodId` with a `catId`.\n\nInstead we can do..\n\n    type Id x\n        = Id String\n\n    updateUsersCatsFavoriteFood : Id User -> Id Cat -> Id Food -> Cmd Msg\n    updateUsersCatsFavoriteFood userId catId foodId =\n        -- ..\n\nNow with `Id x`, it is impossible (again) to mix up a `Id User` with a `Id Cat`. They have different types. And the compiler will point out if you try and use a `Id User` where only a `Id Cat` works.\n\n\n### Okay, there is one trade off\n\nThe following code is not possible due to a circular definition of `User`..\n\n    type alias User =\n        { id : Id User }\n\nEasy work arounds include..\n\n    type UserId\n        = UserId (Id User)\n\n    type alias User =\n        { id : UserId }\n\nand\n\n    type User\n        = User { id : Id User }\n\n..but I would encourage you to build your architecture such that data _does not_ contain its own `Id x` to begin with. Instead, get used to operating on `(Id User, User)` pairs, and treat the left side as the single source of truth for that identifier.\n\n        ( Id User, User )\n\n\n# Id\n\n@docs Id, fromString, toString, encode, decoder, generator\n\n","unions":[{"name":"Id","comment":" ","args":["x"],"cases":[]}],"aliases":[],"values":[{"name":"decoder","comment":" Decode an `Id`\n\n    Decode.decodeString (Decode.field \"id\" Id.decoder) \"{\\\"id\\\":\\\"19\\\"}\"\n    -- Ok (Id \"19\") : Result String Id\n\n","type":"Json.Decode.Decoder (Id.Id x)"},{"name":"encode","comment":" Encode an `Id`\n\n    Encode.encode 0 (Id.encode id)\n    -- \"\"hDFL0Cs2EqWJ4jc3kMtOrKdEUTWh\"\" : String\n\n    [ (\"id\", Id.encode id) ]\n        |> Encode.object\n        |> Encode.encode 0\n\n    -- {\\\"id\\\":\\\"hDFL0Cs2EqWJ4jc3kMtOrKdEUTWh\\\"} : String\n\n","type":"Id.Id x -> Json.Encode.Value"},{"name":"fromString","comment":" Make an id from a string\n\n    Id.fromString \"vq93rUv0A4\"\n\n","type":"String.String -> Id.Id x"},{"name":"generator","comment":" A way to generate random `Id`s\n\n    import Id exposing (Id)\n    import Random exposing (Seed)\n\n    user : Seed -> ( User, Seed )\n    user seed =\n        let\n            ( id, nextSeed ) =\n                Random.step Id.generator seed\n        in\n        ( { id = id, email = \"Bob@sci.org\" }\n        , nextSeed\n        )\n\n","type":"Random.Generator (Id.Id x)"},{"name":"toString","comment":" Extract the string from an id.\n","type":"Id.Id x -> String.String"}],"binops":[]},{"name":"Remote.Db","comment":" This module combines [Kris Jenkin's RemoteData package][kris] with the `Db` type in this package. The kinds of things you store in a relational database are usually fetched from a remote source, and the `RemoteData` type represents whether your data is loading, loaded, or failed to load. By storing data as `RemoteData`, this module can make the assumption that `Id` that are missing from the `Db`are `RemoteData.NotAsked`. This assumption permits our `get` function to return a `RemoteData error item` instead of a `Maybe item` or even a `Maybe (RemoteData error item)`.\n\n\n# Db\n\n@docs Db, empty, Row\n\n\n# Insert\n\n@docs succeed, succeedMany, loading, loadingMany, fail, failMany, insert\n\n\n# Get\n\n@docs get, getWithId, getMany\n\n\n# Update\n\n@docs update\n\n\n# Map\n\n@docs map, mapError, mapItem\n\n\n# Remove\n\n@docs remove\n\n[kris]: https://package.elm-lang.org/packages/krisajenkins/remotedata/latest/\n\n","unions":[{"name":"Db","comment":" Short for \"Database\", it stores data by unique identifiers. The `error` is for loading errors, such as if an http request fails.\n","args":["error","item"],"cases":[]}],"aliases":[{"name":"Row","comment":" A single row in the `Db`; an `Id`, corresponding to either an `item` or the `error` that happend when attempting to load it.\n","args":["error","item"],"type":"( Remote.Id.Id error item, RemoteData.RemoteData error item )"}],"values":[{"name":"empty","comment":" An empty `Db` with no entries\n","type":"Remote.Db.Db error item"},{"name":"fail","comment":" When data fails to load, set it as `Failure` in the `Db`\n","type":"( Remote.Id.Id error item, error ) -> Remote.Db.Db error item -> Remote.Db.Db error item"},{"name":"failMany","comment":" Fail many `Id`, representing them as failing to load in the `Db`\n","type":"List.List ( Remote.Id.Id error item, error ) -> Remote.Db.Db error item -> Remote.Db.Db error item"},{"name":"get","comment":" Get an item out of a `Db`. Notice how it does not return a `Maybe` like `Dict` do. An `Id` that is not present in the `Db` is returned as `RemoteData.NotAsked`.\n","type":"Remote.Db.Db error item -> Remote.Id.Id error item -> RemoteData.RemoteData error item"},{"name":"getMany","comment":" Get many items from a `Db`. The `(id, RemoteData.NotAsked)` case represents the item under that `Id` being absent.\n","type":"Remote.Db.Db error item -> List.List (Remote.Id.Id error item) -> List.List (Remote.Db.Row error item)"},{"name":"getWithId","comment":" Just like `get`, except it comes with the `Id`, for those cases where you dont want the item separated from its `Id`\n","type":"Remote.Db.Db error item -> Remote.Id.Id error item -> Remote.Db.Row error item"},{"name":"insert","comment":" A general insert function into `Db`. You can insert a `RemoteData error item` into a `Db`\n\n    -- if the id is not in the `Db`\n    Remote.Db.get db id\n    --> RemoteData.NotAsked\n\n    -- but if it is..\n    Remote.Db.get\n        (Remote.Db.insert (id, RemoteData.Failure \"Could not load\") db)\n        id\n    --> RemoteData.Failure \"Could not load\"\n\n","type":"Remote.Db.Row error item -> Remote.Db.Db error item -> Remote.Db.Db error item"},{"name":"loading","comment":" Mark the `Id` as `Loading`. After this function is used on a `Db`, it will return `Loading` for that `Id`\n\n    -- if the id is not in the `Db`\n    Remote.Db.get db id\n    --> RemoteData.NotAsked\n\n    -- but if it is..\n    Remote.Db.get (Remote.Db.loading id db) id\n    --> RemoteData.Loading\n\n","type":"Remote.Id.Id error item -> Remote.Db.Db error item -> Remote.Db.Db error item"},{"name":"loadingMany","comment":" Mark a `List` of `Id` as `Loading` in a `Db`\n","type":"List.List (Remote.Id.Id error item) -> Remote.Db.Db error item -> Remote.Db.Db error item"},{"name":"map","comment":" Map a `Db` to a different data type.\n","type":"(a -> b) -> Remote.Db.Db error a -> Remote.Db.Db error b"},{"name":"mapError","comment":" Map the error type of a `Db` to something else.\n","type":"(a -> b) -> Remote.Db.Db a item -> Remote.Db.Db b item"},{"name":"mapItem","comment":" Apply a change to just one item in the `Db`, assuming the item is in the `Db` in the first place. This function is just like `update` except deleting the item is not possible.\n","type":"Remote.Id.Id error item -> (item -> item) -> Remote.Db.Db error item -> Remote.Db.Db error item"},{"name":"remove","comment":" Simply remove an `Id` from a `Db`, resetting that item to `RemoteData.NotAsked`\n\n    Remote.Db.get (Remote.Db.remove id db) id\n    --> RemoteData.NotAsked\n\n","type":"Remote.Id.Id error item -> Remote.Db.Db error item -> Remote.Db.Db error item"},{"name":"succeed","comment":" Insert an `item` into a `Db`, when it has been successfully loaded\n","type":"( Remote.Id.Id error item, item ) -> Remote.Db.Db error item -> Remote.Db.Db error item"},{"name":"succeedMany","comment":" Insert many `item`s into a `Db`, such as when you loaded many items successfully.\n","type":"List.List ( Remote.Id.Id error item, item ) -> Remote.Db.Db error item -> Remote.Db.Db error item"},{"name":"update","comment":" Update an item in a `Db`, using an update function. If the item doesnt exist in the `Db`, it comes into the update as `RemoteData.NotAsked`. If a `RemoteData.NotAsked` comes out of the update function, the value under that id will be removed.\n","type":"Remote.Id.Id error item -> (RemoteData.RemoteData error item -> RemoteData.RemoteData error item) -> Remote.Db.Db error item -> Remote.Db.Db error item"}],"binops":[]},{"name":"Remote.Id","comment":" Much like the `Id` type in the non-remote version of this module, except now the `Id` might also point to the `error` that occured when trying to load the `item`.\n\n\n# Id\n\n@docs Id, fromString, toString, encode, decoder, generator\n\n","unions":[{"name":"Id","comment":" ","args":["error","x"],"cases":[]}],"aliases":[],"values":[{"name":"decoder","comment":" Decode an `Id`\n\n    Decode.decodeString (Decode.field \"id\" Id.decoder) \"{\\\"id\\\":\\\"19\\\"}\"\n    -- Ok (Id \"19\") : Result String Id\n\n","type":"Json.Decode.Decoder (Remote.Id.Id error x)"},{"name":"encode","comment":" Encode an `Id`\n\n    Encode.encode 0 (Id.encode id)\n    -- \"\"hDFL0Cs2EqWJ4jc3kMtOrKdEUTWh\"\" : String\n\n    [ (\"id\", Id.encode id) ]\n        |> Encode.object\n        |> Encode.encode 0\n\n    -- {\\\"id\\\":\\\"hDFL0Cs2EqWJ4jc3kMtOrKdEUTWh\\\"} : String\n\n","type":"Remote.Id.Id error x -> Json.Encode.Value"},{"name":"fromString","comment":" Make an id from a string\n\n    Id.fromString \"vq93rUv0A4\"\n\n","type":"String.String -> Remote.Id.Id error x"},{"name":"generator","comment":" A way to generate random `Id`s\n\n    import Id exposing (Id)\n    import Random exposing (Seed)\n\n    user : Seed -> ( User, Seed )\n    user seed =\n        let\n            ( id, nextSeed ) =\n                Random.step Id.generator seed\n        in\n        ( { id = id, email = \"Bob@sci.org\" }\n        , nextSeed\n        )\n\n","type":"Random.Generator (Remote.Id.Id error x)"},{"name":"toString","comment":" Extract the string from an id.\n","type":"Remote.Id.Id error x -> String.String"}],"binops":[]}]