DISCLAIMER: This is a work in progress, not ready for production yet. Contribution and PR are welcome! 🙂
Thin wrapper around Horizon JavaScript client API for writing Horizon application in Elm.
*Cmd -> String -> List Json.Value -> Cmd msg
Insert / replace / store / update / upsert / remove one or more new documents into a Collection.
collectionName
is the name of the Horizon collectionvalues
is List of encoded Json.Value you want to insert / replace / store / update / upsert / remove to the collection.
insertCmd "chat_messages" [ chatMessageEncoder { id = 1, from = "elm", message = "Hello World!" } ]
removeAllCmd "chat_messages" <| List.map Json.Encode.int [ 1, 2, 3 ]
removeCmd -> String -> Json.Value -> Cmd msg
collectionName
is the name of the Horizon collectionvalue
is the encoded Json.Value of the id/record of the data you want to delete.
removeCmd "chat_messages" <| Json.Encode.int 1
*Sub -> (Result Error () -> msg) -> Sub msg
Subscription for the result of Insert / replace / store / update / upsert / remove operation.
tagger
is the constructor for your msg that requires aResult
type Msg = InsertResponse (Result Error ())
subscriptions = insertSub InsertResponse
*Cmd -> String -> List Modifier -> Cmd msg
collectionName
is the name of the Horizon collectionmodifiers
is the List of Modifier
watchCmd "chat_messages" [ Limit 10, Order "name" Ascending ]
*Sub -> Decoder a -> (Result Error (List (Maybe a)) -> msg) -> Sub msg
decoder
is the decoder for decoding the datatagger
is msg constructor for tagging the decoded data
type Msg = NewMessageMsg (Result Error (List (Maybe ChatMessage)))
subscriptions = watchSub NewMessageMsg
Restrict the range of results returned to values that sort above a given value.
Above <| encoder { price = 100.0 }
Restrict the range of results returned to values that sort below a given value.
Below <| encoder { value = 20 }
Retrieve a single document from a Collection.
Find <| encoder { id = 1 }
Retrieve multiple documents from a Collection.
FindAll [ encoder { id = 1 }, encoder { id = 2 }]
Limit 10
where Direction
can be:
Ascending
Descending
Order "timestamp" Ascending
To build and run the example, clone the repo, and then from the root folder of the repo, run this command:
$ npm install
$ npm start
and then open http://localhost:8000 from your browser to open the chat app, or http://localhost:8000/search.html to open the search app.
Make sure you have Horizon and RthinkDB installed on your machine. See http://horizon.io/install/ for installation instruction.
TBA
TBA
TBA