IzumiSy/elm-firestore/10.0.1

NOTE: the latest version is 13.0.0

Firestore.Decode

Decoders for Firestore

type Decoder a

A decoder consisted of Firestore specific decoders.

Json.Decode.Decoder can be generate from this through decode function.

decode : Decoder a -> Decoder a

Generates Json.Decode.Decoder

type Field a

An identifier type for Firestore encoder

Constructors

document : a -> Decoder a

Creates a new decoder

This function works like Json.Decode.Pipeline.

Firestore.Decode.document Document
    |> Firestore.Decode.required "name" Firestore.Decode.string
    |> Firestore.Decode.required "age" Firestore.Decode.int
    |> Firestore.Decode.optional "canCode" Firestore.Decode.bool False
required : String -> Field a -> Decoder (a -> b) -> Decoder b

Decodes a required field.

This function is internally delegated into json.Decode.Pipeline.required.

optional : String -> Field a -> a -> Decoder (a -> b) -> Decoder b

Decodes an optional field.

This function is internally delegated into Json.Decode.Pipeline.optional.

Types

bool : Field Bool
bytes : Field String
int : Field Int
string : Field String
list : Field a -> Field (List a)
dict : Field a -> Field (Dict String a)
null : Field ()
maybe : Field a -> Field (Maybe a)

Utility Functions

map : (a -> b) -> Field a -> Field b
andThen : (a -> Field b) -> Field a -> Field b
succeed : a -> Field a
fail : String -> Field a