{"id":23361098,"url":"https://github.com/aitem/bdm","last_synced_at":"2026-02-04T15:32:53.670Z","repository":{"id":144729046,"uuid":"282724446","full_name":"Aitem/bdm","owner":"Aitem","description":"BDM is super simple, fully declarative clj/cljc bi directional mapper.","archived":false,"fork":false,"pushed_at":"2024-10-23T05:56:51.000Z","size":44,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T15:12:31.501Z","etag":null,"topics":["bdm","bidirectional","clojure","clojurescript","data-driven","dsl","mapper"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aitem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-26T20:05:03.000Z","updated_at":"2024-10-10T10:50:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"045a3059-6673-446f-bc42-6cc6eff2b50d","html_url":"https://github.com/Aitem/bdm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Aitem/bdm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aitem%2Fbdm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aitem%2Fbdm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aitem%2Fbdm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aitem%2Fbdm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aitem","download_url":"https://codeload.github.com/Aitem/bdm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aitem%2Fbdm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29088571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T03:31:03.593Z","status":"ssl_error","status_checked_at":"2026-02-04T03:29:50.742Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bdm","bidirectional","clojure","clojurescript","data-driven","dsl","mapper"],"created_at":"2024-12-21T11:17:21.443Z","updated_at":"2026-02-04T15:32:53.644Z","avatar_url":"https://github.com/Aitem.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BiDirectionalMapper\n\n[![Clojars Project](https://img.shields.io/clojars/v/bdm.svg)](https://clojars.org/bdm)\n![ci](https://github.com/aitem/bdm/workflows/CI/badge.svg)\n\n\nBDM is super simple, fully declarative clj/cljc bi directional mapper that allow convert your data from `A` to `B` and back.\n\n## Usage\n\n``` clj\n(ns user\n  (:require [bdm.core as bdm]))\n\n(def person\n  {:name \"John\"\n   :lastname \"Smith\"\n   :contacts [{:type  \"email\"\n               :value \"john@smith.com\"}\n              {:type  \"phone\"\n               :use   \"home\"\n               :value \"12223334455\"}\n\t\t\t  {:type  \"phone\"\n\t\t\t   :use   \"work\"\n\t\t\t   :value \"15556667788\"}]})\n\n(def mapping\n  [[[:name]]\n   [[:lastname]]\n   [[:emails] [:contacts {:get [:= :type \"email\"]} :#]]\n   [[:phones] [:contacts {:get [:= :type \"phone\"]} :#]]])\n\n(bdm/import person mapping)\n\n;; Will return\n;; {:name \"John\",\n;;  :lastname \"Smith\",\n;;  :emails [{:type \"email\", :value \"john@smith.com\"}],\n;;  :phones [{:type \"phone\", :use \"home\", :value \"12223334455\"}\n;;           {:type \"phone\", :use \"vork\", :value \"15556667788\"}]}\n\n\n;; We can do import/export roundtrip\n\n(= person (bdm/export (bdm/import person mapping) mapping)) ;; =\u003e true\n\n```\n\n## Concepts\n\n### Mapping\n\n`Mapping` is a array of `paths` pairs. First `path` of pair used as setter rule and second as a getter rule.\n\n``` clj\n(def mapping\n  [[[:username] [:login]]])\n\n(def user\n  {:login \"super-user\"})\n\n(bdm/import user mapping)\n;; will return\n;; {:username \"super-user\"}\n\n(def imported-user\n  {:username \"super-user\"})\n\n(bdm/export imported-user mapping)\n;; will return\n;; {:login \"super-user\"}\n```\n\nIn this sample we take value from `user` by path `[:login]` and set this value into result with path `[:username]`.\n\nPath can be deep\n\n``` clj\n(def window-mapping\n  [[[:hash] [:window :location :hash]]\n   [[:path] [:window :location :pathname]]])\n\n(def window\n  {:window {:location {:hash     \"#about\"\n                       :pathname \"/index.html\"}}})\n\n(bdm/import window window-mapping)\n;; Will return\n;; {:hash \"#about\"\n;;  :path \"/index.html\"}\n\n(def location\n {:hash \"#contact\"\n  :path \"/spa.html\"})\n\n(bdm/export location window-mapping)\n;; Will return\n;; {:window {:location {:hash     \"#contact\"\n;;                      :pathname \"/spa.html\"}}})\n```\n\n\n\n### Path\n...\n\n### Short alias\n...\n\n### Predicates and arrays\n...\n\n### Setters\n...\n\n### Submapping\n...\n\n\n\n## Develop\n\n```\n# run repl\n$ make repl\n\n# run test\n$ make test\n```\n\n## Extra\n\nFor more details and usage details see tests.\n\n\n\nMIT License Copyright (c) 2020 Marat Surmashev\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faitem%2Fbdm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faitem%2Fbdm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faitem%2Fbdm/lists"}