IzumiSy / elm-firestore / 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 -> Json.Decode.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 Basics.Bool

bytes : Field String

int : Field Basics.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)

timestamp : Field Time.Posix

geopoint : Field Firestore.Types.Geopoint.Geopoint

reference : Field Firestore.Types.Reference.Reference

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