{"id":20141270,"url":"https://github.com/alekcz/datahike-firebase","last_synced_at":"2025-04-09T18:41:02.904Z","repository":{"id":57713079,"uuid":"257387631","full_name":"alekcz/datahike-firebase","owner":"alekcz","description":"Datahike with Firebase as data storage","archived":false,"fork":false,"pushed_at":"2022-09-15T20:08:30.000Z","size":53,"stargazers_count":50,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-14T01:05:58.333Z","etag":null,"topics":["clojure","datahike","firebase","firetomic","konserve"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alekcz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-20T19:48:26.000Z","updated_at":"2023-05-29T17:20:30.000Z","dependencies_parsed_at":"2022-09-06T02:10:31.760Z","dependency_job_id":null,"html_url":"https://github.com/alekcz/datahike-firebase","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alekcz%2Fdatahike-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alekcz%2Fdatahike-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alekcz%2Fdatahike-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alekcz%2Fdatahike-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alekcz","download_url":"https://codeload.github.com/alekcz/datahike-firebase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427859,"owners_count":20937357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","datahike","firebase","firetomic","konserve"],"created_at":"2024-11-13T21:56:53.399Z","updated_at":"2025-04-09T18:41:02.882Z","avatar_url":"https://github.com/alekcz.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# datahike-firebase\n\n[Datahike](https://github.com/replikativ/datahike) with [Firebase](https://firebase.google.com/products/realtime-database) as data storage.\n\n## Status\n![master](https://github.com/alekcz/datahike-firebase/workflows/master/badge.svg) [![codecov](https://codecov.io/gh/alekcz/datahike-firebase/branch/master/graph/badge.svg)](https://codecov.io/gh/alekcz/datahike-firebase)   \n\n## Prerequisites\n\nFor datahike-firebase you will need to create a Realtime Database on Firebase and store the service account credentials in the an environment variable.\n\n## Usage\n\n[![Clojars Project](https://img.shields.io/clojars/v/alekcz/datahike-firebase.svg)](https://clojars.org/alekcz/datahike-firebase)\n\n`[alekcz/datahike-firebase \"0.5.1506\"]`\n\nAfter including the datahike API and the datahike-firebase namespace, you can use the Firebase backend now using the keyword `:firebase`\n\n```clojure\n(ns project.core\n  (:require [datahike.api :as d]\n            [datahike-firebase.core]))\n\n;; Create a config map with firebase as storage medium\n(def config {:store {:backend :firebase\n                     :env \"GOOGLE_APPLICATION_CREDENTIALS\" ;environment variable with services account details \n                     :db \"https://firebase-db-name.firebaseio.com\" ; \n                     :root \"datahike\"}\n             :schema-flexibility :read\n             :keep-history? false})\n\n(def config2 {:store {:backend :firebase\n                     :db \"http://localhost:9000\" ;connect to the local emulator\n                     :root \"datahike\"}\n             :schema-flexibility :read\n             :keep-history? false})\n\n;; Create a database at this place, by default configuration we have a strict\n;; schema and temporal index\n(d/create-database config)\n\n(def conn (d/connect config))\n\n;; The first transaction will be the schema we are using:\n(d/transact conn [{:db/ident :name\n                   :db/valueType :db.type/string\n                   :db/cardinality :db.cardinality/one }\n                  {:db/ident :age\n                   :db/valueType :db.type/long\n                   :db/cardinality :db.cardinality/one }])\n\n;; Let's add some data and wait for the transaction\n(d/transact conn [{:name  \"Alice\", :age   20 }\n                  {:name  \"Bob\", :age   30 }\n                  {:name  \"Charlie\", :age   40 }\n                  {:age 15 }])\n\n;; Search the data\n(d/q '[:find ?e ?n ?a\n       :where\n       [?e :name ?n]\n       [?e :age ?a]]\n  @conn)\n;; #{[4 \"Bob\" 30] [5 \"Charlie\" 40] [3 \"Alice\" 20]}\n\n;; Clean up the database if it is not needed any more\n(d/delete-database config)\n```\n\n## License\n\nCopyright © 2020 Alexander Oloo\n\nThis program and the accompanying materials are made available under the\nterms of the Eclipse Public License 2.0 which is available at\nhttp://www.eclipse.org/legal/epl-2.0.\n\nThis Source Code may also be made available under the following Secondary\nLicenses when the conditions for such availability set forth in the Eclipse\nPublic License, v. 2.0 are satisfied: GNU General Public License as published by\nthe Free Software Foundation, either version 2 of the License, or (at your\noption) any later version, with the GNU Classpath Exception which is available\nat https://www.gnu.org/software/classpath/license.html.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falekcz%2Fdatahike-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falekcz%2Fdatahike-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falekcz%2Fdatahike-firebase/lists"}