A lightweight clojure client for Firebase based using the REST API. Basically Charmander 2.0
Pre-alpha
For konserve-fire you will need to create a Realtime Database on Firebase and store the service account credentials in the an environment variable. The default variable is GOOGLE_APPLICATION_CREDENTIALS
[alekcz/fire "0.1.0"]
Write to the specified location (will overwrite any existing data):
(fire/write! "protected-db-name" "/path" {:map "with data"} auth)
(fire/write! "public-db-name" "/path" {:map "with data"})
; => {:map "with data"}
Read data from the specified location:
(fire/read "protected-db-name" "/path" auth)
(fire/read "public-db-name" "/path")
; => {:map "with data"}
Update data at the specified location (only updates the specified fields):
(fire/update! "protected-db-name" "/path" {:more "data"} auth)
(fire/update! "public-db-name" "/path" {:more "data"})
; => {:map "with data" :more "data"}
Add data at the specified location with an automatically generated key:
(fire/push! "protected-db-name" "/path" {:map "with data"} auth)
(fire/push! "public-db-name" "/path" {:map "with data"})
; => {"name" "-IoZ3DZlTTQIkR0c7iVK"}
Delete at the specified locations:
(fire/delete! "protected-db-name" "/path" auth)
(fire/delete! "public-db-name" "/path")
; => nil
Query data at the specified locations:
Note that if the child key is not indexed firebase will respond with error 400. Also :orderBy
is required for all queries.
See the Firebase query docs for more info.
(fire/read "protected-db-name" "/path" auth {:orderBy "child-key" :startAt 10 :endAt 50})
(fire/read "protected-db-name" "/path" auth {:orderBy "child-key" :equalTo 10})
(fire/read "public-db-name" "/path" nil {:orderBy "child-key" :limitToFirst 10})
(fire/read "public-db-name" "/path" nil {:orderBy "child-key" :limitToLast 3})
; => nil
Special thanks to:
Copyright © 2020 Alexander Oloo
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close