IzumiSy/elm-firestore/4.0.0

NOTE: the latest version is 13.0.0

Firestore

A library to have your app interact with Firestore in Elm

Data type for Firestore

Builds a new Firestore connection with Config

Drills down document paths with a specific path name.

This function is aimed to be chanind with pipeline operators in order to build up document path.

firestore
    |> Firestore.collection "users"
    |> Firestore.collection "items"
    |> Firestore.collection "tags"
    |> Firestore.get
    |> Task.attempt GotUserItemTags

Of course, you can make it a single string as well

firestore
    |> Firestore.collection "users/items/tags"
    |> Firestore.get
    |> Task.attempt GotUserItemTags

Updates configuration

CRUDs

type alias Document a =
{ name : String
, fields : a
, createTime : Posix
, updateTime : Posix
}

A record structure for a document fetched from Firestore.

get : Decoder a -> Firestore -> Task Error (Document a)

Gets a single document.

list : Decoder a -> Firestore -> Task Error (List (Document a))

Lists documents.

type Draft

A type for a document before persisted on Firestore.

draft : List ( String, Field ) -> Draft

Creates a new document for create or patch.

create : Decoder a -> Draft -> Firestore -> Task Error (Document a)

Creates a new document.

patch : Decoder a -> Draft -> Firestore -> Task Error (Document a)

Updates or inserts a document.

delete : Firestore -> Task Error ()

Deletes a document.

Error

type Error
= Http_ Error
| Response FirestoreError

An error type

This type is available in order to disregard type of errors between protocol related errors as Http_ or backend related errors as Response.

type alias FirestoreError =
{ code : Int
, message : String
, status : String
}

Data structure for errors from Firestore

Transaction

Data type for Transaction

type alias CommitTime =
Posix

A time transaction commited at

Starts a new transaction.

commit : Transaction -> Firestore -> Task Error CommitTime

Commits a transaction, while optionally updating documents.

Only readWrite transaction is supported.

Adds a new update into the transaction