{"id":16660590,"url":"https://github.com/mpenet/hayt","last_synced_at":"2025-04-07T13:08:39.143Z","repository":{"id":6944691,"uuid":"8196414","full_name":"mpenet/hayt","owner":"mpenet","description":"CQL3 DSL for Clojure","archived":false,"fork":false,"pushed_at":"2020-09-22T09:14:53.000Z","size":836,"stargazers_count":72,"open_issues_count":0,"forks_count":20,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-01T23:59:13.524Z","etag":null,"topics":["cassandra","cassandra-cql","clojure","cql","dsl"],"latest_commit_sha":null,"homepage":"http://mpenet.github.io/hayt/codox/qbits.hayt.html","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/mpenet.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":"FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"mpenet"}},"created_at":"2013-02-14T09:01:55.000Z","updated_at":"2023-12-21T18:32:31.000Z","dependencies_parsed_at":"2022-08-26T07:11:54.085Z","dependency_job_id":null,"html_url":"https://github.com/mpenet/hayt","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpenet%2Fhayt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpenet%2Fhayt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpenet%2Fhayt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpenet%2Fhayt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpenet","download_url":"https://codeload.github.com/mpenet/hayt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657281,"owners_count":20974345,"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":["cassandra","cassandra-cql","clojure","cql","dsl"],"created_at":"2024-10-12T10:29:55.088Z","updated_at":"2025-04-07T13:08:39.101Z","avatar_url":"https://github.com/mpenet.png","language":"Clojure","funding_links":["https://github.com/sponsors/mpenet"],"categories":[],"sub_categories":[],"readme":"# Hayt [![Build Status](https://secure.travis-ci.org/mpenet/hayt.png?branch=master)](http://travis-ci.org/mpenet/hayt) [![cljdoc badge](https://cljdoc.xyz/badge/cc.qbits/hayt)](https://cljdoc.xyz/d/cc.qbits/hayt/CURRENT)\n\nCQL3 DSL for Clojure.\n\n## What?\n\nHayt is a thin query DSL for CQL.\n\nIt works in 2 simple steps, first the query api generates a map (AST)\nrepresentation of the query, allowing you to compose/modify it at\nwill, then there's a compilation step that will generate a raw string\nfor you to use in prepared statements or normal queries.\n\nBoth are decoupled, so you can just use the AST directly and make your\nown api on top of it if that's what you like.\n\n## What's in the box?\n\n* **Complete CQL 3.1.1+ coverage** including some features in Cassandra\n  trunk, **DDL**, **CQL Functions**, **counter** , **triggers** and\n  **collections** operations\n* Support for both **Raw queries** and **Prepared Statements** generation\n* **Great performance** (lots of transducing and fiddling with StringBuilder)\n* **Extensive test coverage**\n* Decoupled query compiler, allowing you to **build your own DSL** in minutes\n* Highly **composable** using simple maps or the functions provided\n* Extensible **Clojure data types support**\n* Constantly **kept up to date** with Cassandra changes, almost daily\n* No (exposed) macros\n\n## Installation\n\nPlease check the\n[Changelog](https://github.com/mpenet/hayt/blob/master/CHANGELOG.md) first\nif you are upgrading.\n\n[![Clojars Project](https://img.shields.io/clojars/v/cc.qbits/hayt.svg)](https://clojars.org/cc.qbits/hayt)\n\nNote: while in beta the API is still subject to changes.\n\n## Usage\n\nThis should be familiar if you know Korma or ClojureQL.\nOne of the major differences is that Hayt doesn't expose macros.\n\n\n```clojure\n\n(use 'qbits.hayt)\n\n(select :foo\n        (where {:bar 2}))\n\n(update :some-table\n         (set-columns {:bar 1\n                       :baz (inc-by 2)})\n         (where [[= :foo :bar]\n                 [\u003e :moo 3]\n                 [:\u003e :meh 4]\n                 [:in :baz [5 6 7]]]))\n```\n\nAll these functions do is generate maps, if you want to build your own\nDSL on top of it or use maps directly, feel free to do so.\n\n```clojure\n(select :users\n        (columns :a :b)\n        (where [[= :foo :bar]\n                [\u003e :moo 3]\n                [:\u003e :meh 4]\n                [:in :baz [5 6 7]]])})\n\n;; generates the following\n\n\u003e\u003e {:select :users\n    :columns [:a :b]\n    :where [[= :foo :bar]\n            [\u003e :moo 3]\n            [:\u003e :meh 4]\n            [:in :baz [5 6 7]]]}\n```\n\nSince Queries are just maps they are composable using the usual `merge`\n`into` `assoc` etc.\n\n```clojure\n(def base (select :foo (where {:foo 1})))\n\n(merge base\n       (columns :bar :baz)\n       (where {:bar 2})\n       (order-by [:bar :asc])\n       (using :ttl 10000))\n\n```\n\nTo compile the queries just use `-\u003eraw`\n\n```clojure\n(-\u003eraw (select :foo))\n\u003e \"SELECT * FROM foo;\"\n\n\n(-\u003eraw {:select :foo :columns [:a :b]})\n\u003e \"SELECT a, b FROM foo;\"\n\n;; or if you want full control of what's prepared you can use\n;; `cql-raw` with -\u003eraw compilation:\n\n\n;; here `?` is an alias to `(cql-raw \"?\")`\n\n(-\u003eraw (select :foo (where {:bar 1 :baz ?})))\n\u003e \"SELECT * FROM foo WHERE bar = 1 AND baz = ?;\"\n\n\n;; and named parameters using keywords\n\n(-\u003eraw (select :foo (where {:bar 1 :baz :named)}))\n\u003e \"SELECT * FROM foo WHERE bar = 1 AND baz = :named;\"\n```\n\nWhen compiling with `-\u003eraw` we take care of the encoding/escaping\nrequired by CQL. This process is also open via the\n`qbits.hayt.CQLEntities` protocol for both values and identifiers. We\nalso supply a joda-time codec for you to use if you require to in\n`qbits.hayt.codec.joda-time`. This codec is a good example of how to\nhandle custom type encoding.\n\nIf you are curious about what else it can do, head to the\n[codox documentation](http://mpenet.github.com/hayt/codox/qbits.hayt.html)\nor the\n[tests](https://github.com/mpenet/hayt/blob/master/test/qbits/hayt/core_test.clj).\n\n## License\n\nCopyright @[Max Penet](https://twitter.com/mpenet)\n\nDistributed under the Eclipse Public License, the same as Clojure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpenet%2Fhayt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpenet%2Fhayt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpenet%2Fhayt/lists"}