{"id":13800675,"url":"https://github.com/pandeiro/jaki","last_synced_at":"2025-10-22T02:22:23.712Z","repository":{"id":2006330,"uuid":"2940176","full_name":"pandeiro/jaki","owner":"pandeiro","description":"A simple ClojureScript CouchDB client","archived":false,"fork":false,"pushed_at":"2012-10-10T12:26:10.000Z","size":143,"stargazers_count":16,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-05T09:38:04.905Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pandeiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-08T13:22:55.000Z","updated_at":"2023-07-25T13:43:54.000Z","dependencies_parsed_at":"2022-09-20T22:44:35.927Z","dependency_job_id":null,"html_url":"https://github.com/pandeiro/jaki","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandeiro%2Fjaki","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandeiro%2Fjaki/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandeiro%2Fjaki/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandeiro%2Fjaki/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pandeiro","download_url":"https://codeload.github.com/pandeiro/jaki/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253913206,"owners_count":21983273,"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":[],"created_at":"2024-08-04T00:01:14.985Z","updated_at":"2025-10-22T02:22:18.669Z","avatar_url":"https://github.com/pandeiro.png","language":"Clojure","funding_links":[],"categories":["Libraries","Awesome ClojureScript"],"sub_categories":["Document Versioning","Database"],"readme":"Jaki 0.1.0\n==========\n*Browser-based [CouchDB](http://couchdb.apache.org) applications with [ClojureScript](http://github.com/clojure/clojurescript)*\n\nJaki's principal components are\n\n* `src/jaki/req.cljs`: a request client that automatically converts Clojure and JavaScript datatypes\n* `src/jaki/couch.cljs`: a basic library covering most of the CouchDB API using Clojure idioms\n* `couchapp-template` \u0026 `script/jaki`: a template and script for generating new projects (to be used with the [couchapp](https://github.com/couchapp/couchapp) upload tool).\n\nUsage\n-----\n\nWith leiningen:\n\n```clojure\n[jaki \"0.1.0\"]\n```\n\n...or just copy the `src/jaki` directory to your ClojureScript project.\n\nUse or require the library's namespace:\n\n```clojure\n(ns myapp.core\n  (:require [jaki.couch :as couch]))\n\n(couch/all-dbs (fn [dbs] (js/alert (apply str (interpose \", \" dbs)))))\n```\n\nSetup\n-----\n\nJaki will automatically try to use the URL path to determine the current database, although\nyou can always specify the database in each request as well.\n\nYou also have the option of setting a default database to use:\n\n```clojure\n(couch/set-default-db \"jazz\")\n(couch/get-docs (fn [resp] (js/alert (str (count (:rows resp)) \" docs found in 'jazz' database\"))))\n```\n\nIf you are able to do cross-domain XHR requests, as with browser extensions, you can set the host like so:\n\n```clojure\n(couch/set-host! \"http://username.iriscouch.com\")\n```\n\nIf your endpoint is not at the root of the URL path, you can set a prefix like so:\n```clojure\n(couch/set-url-prefix \"myapp\")\n```\n\nCouch CRUD\n----------\n\nJaki abstracts CRUD operations to three main functions: `get-docs`, `post-docs`, and `delete-docs`.\n\n### `get-docs`\n\nAt its simplest, Jaki guesses the current database (or taps a default database if set), and requests all documents (with include_docs=true):\n\n```clojure\n(get-docs (fn [resp] (js/alert (str (-\u003e resp :rows count) \" documents found!\"))))\n```\n\nThere's also some sugar for limiting the number of results (also implies include_docs=true):\n\n```clojure\n(get-docs 10 (fn [resp] \n               (js/alert (apply str (map #(str %2 \". \" (:id %1) \"\\n\") (:rows resp) (iterate inc 1))))))\n```\n\nAnd there's sugar for specifying just the document(s) you want by id, like so (also implies include_docs=true):\n\n```clojure\n(get-docs [\"_design/app\" \"_design/test\"]\n          (fn [docs] (js/alert (str (count (map #(-\u003e % :views keys) docs)) \" total views found\"))))\n```\n\nFor more granular control, specify a view-map with a database and/or design document, view, and options (no implict include_docs=true):\n\n```clojure\n(get-docs {:db \"articles\" :design \"blog\" :view \"most-recent\" :descending true :include_docs true :limit 10}\n          (fn [resp] (js/alert (-\u003e resp :rows first :doc :title))))\n```\n\n### `post-docs`\n\nYou can save a document (map) or vector of documents, with or without a callback, and with or \nwithout specifying the database:\n\n```clojure\n(post-docs {:_id \"b9725ae4542ce6252937\" :_rev \"3-a2362326892374879692\"} (fn [resp] (js/alert \"Updated!\")))\n\n(post-docs \"albums\" [{:title \"St. Louis Blues\" :album \"Sunshine of my Soul\" :recorded -68508000000}\n                     {:title \"Parisian Thoroughfare\" :album \"The Jaki Byard Experience\" :recorded -40683600000}])\n```\n\n### `delete-docs`\n\nLikewise, documents can be deleted in the same way they are posted:\n\n```clojure\n(delete-docs {:_id \"b9725ae4542ce6252937\" :_rev \"3-a2362326892374879692\"})\n\t\n(delete-docs \"albums\" [{:_id \"ce672987ad32919732523b6\" :_rev \"2-ab4452cd382236274346\"}\n                       {:_id \"ce672987ad32919732527f9\" :_rev \"1-f32353a25bc544574232\"}]\n             (fn [resp] (js/alert \"Deleted!\")))\n```\n\nThere's also sugar for when you don't have the rev handy, in which case you can just use the\nid string, though this has a performance penalty of an extra request behind-the-scenes to retrieve\nthe _rev:\n\n```clojure\n(delete-docs [\"ce672987ad32919732523b6\" \"ce672987ad32919732527f9\"])\n```\n\nApp Generator Script\n--------------------\n\nTo generate an application skeleton, edit `jaki/script` to use the appropriate template location, make sure it's executable,\nplace the script somewhere in your `$PATH`, and run it:\n\n    jaki new myapp\n\nThis will create a new subdirectory `myapp` in the current directory, containing `app` and `src` subdirectories. Inside `app`\nwill be a basic couchapp structure with an `index.html` that already contains a reference to your app and the entrypoint invocation\n`myapp.start()`.\n\nFrom here, simply specify authentication credentials and target database in `.couchapprc` and compile the `src` subdirectory\nand you are ready to push your couchapp.\n\n\nAPI Todo\n--------\n\n- Listening for _changes\n\n- Replication\n\nContributing\n------------\n\nThis is my first real attempt at writing a library and using ClojureScript. I am very grateful to anyone who wants to use, test,\nor contribute to this project. You can get in touch with me here on github or on freenode's `#clojure` and `#couchdb` channels.\n\n\nLicense\n-------\n\nCopyright (C) 2011 Murphy McMahon\n\nDistributed under the Eclipse Public License, the same as Clojure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandeiro%2Fjaki","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpandeiro%2Fjaki","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandeiro%2Fjaki/lists"}