{"id":16889686,"url":"https://github.com/benoitc/couchc","last_synced_at":"2025-04-11T13:00:33.246Z","repository":{"id":1550527,"uuid":"1931118","full_name":"benoitc/couchc","owner":"benoitc","description":"minimal couchdb internal API wrapper","archived":false,"fork":false,"pushed_at":"2011-07-31T09:50:11.000Z","size":154,"stargazers_count":14,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T10:07:20.795Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benoitc.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}},"created_at":"2011-06-21T19:38:50.000Z","updated_at":"2020-01-21T11:11:12.000Z","dependencies_parsed_at":"2022-08-16T13:45:16.324Z","dependency_job_id":null,"html_url":"https://github.com/benoitc/couchc","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/benoitc%2Fcouchc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fcouchc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fcouchc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fcouchc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benoitc","download_url":"https://codeload.github.com/benoitc/couchc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248404234,"owners_count":21097687,"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-10-13T16:58:22.041Z","updated_at":"2025-04-11T13:00:33.116Z","avatar_url":"https://github.com/benoitc.png","language":"Erlang","readme":"# couchc\n\nSimple CouchDB API internal wrapper. \n\nThis library wrap CouchDB intenal API in simple call to help you in\nbuilding CouchDB plugings.\n\nThis api is compatible with CouchDb 1.1.x and trunk (1.2.x) .\n\n## Build\n\n    $ export COUCHDB_SRC=/path/to/sources/src/couchdb\n    $ erlc -I $COUCHDB_SRC *.erl\n\nNote: Move it in couchdb beam folder if you want to use it easily.\n\n## Getting started\n\n### Create a database\n\n    Options = [{user_ctx, #user_ctx{roles=[\u003c\u003c\"_admin\"\u003e\u003e]}}],\n    {ok, Db} = couchc:create_db(\"couchc_testdb\", Options).\n\n\n### Save a document\n\n    Doc = {[{\u003c\u003c\"_id\"\u003e\u003e, \u003c\u003c\"doc1\"\u003e\u003e}, {\u003c\u003c\"v\"\u003e\u003e, 1}]},\n    {pk, DocID, DocRev} =  couchc:save_doc(Db, Doc).\n\n### Open a document\n\n    {ok, Doc1} = couchc:open_doc(Db, DocId).\n\n### Delete a document\n\n    {ok, DocID, NewDocRev} = couchc:delete_doc(Doc, {DocId, DocRev}).\n\n### Save multiple documents\n\n    Docs = [\n            {[{\u003c\u003c\"_id\"\u003e\u003e, \u003c\u003c\"a\"\u003e\u003e}, {\u003c\u003c\"v\"\u003e\u003e, 1}, {\u003c\u003c\"t\"\u003e\u003e, \u003c\u003c\"test\"\u003e\u003e}]},\n            {[{\u003c\u003c\"_id\"\u003e\u003e, \u003c\u003c\"b\"\u003e\u003e}, {\u003c\u003c\"v\"\u003e\u003e, 2}, {\u003c\u003c\"t\"\u003e\u003e, \u003c\u003c\"test\"\u003e\u003e}]}],\n    Results = couchc:save_docs(Db, Docs),\n\n### Get all documents\n\n    {ok, {TotalRowsCount, Offset, Results1}} = couchc:all(Db).\n\n### Views\n\n    DesignDoc = {[\n            {\u003c\u003c\"_id\"\u003e\u003e, \u003c\u003c\"_design/test\"\u003e\u003e},\n            {\u003c\u003c\"language\"\u003e\u003e,\u003c\u003c\"javascript\"\u003e\u003e},\n            {\u003c\u003c\"views\"\u003e\u003e,\n                {[{\u003c\u003c\"v1\"\u003e\u003e,\n                    {[{\u003c\u003c\"map\"\u003e\u003e,\n                        \u003c\u003c\"function (doc) {\\n if (doc.t == \\\"test\\\") {\\n emit(doc._id, doc);\\n}\\n}\"\u003e\u003e\n                    }]}\n        }]}}]},\n    \n    {ok, _, _} = couchc:save_doc(Db, DesignDoc),\n    {ok, {TotalRowsCount, Offset, Results1}} = couchc:all(Db, {\u003c\u003c\"test\"\u003e\u003e, \u003c\u003c\"v1\"\u003e\u003e})\n\nThis function get all documents in the view. You can use fold instead of\nall to fold documents. the all function is written like this:\n\n\n    collect_results(Row, Acc) -\u003e\n        {ok, [Row | Acc]}.\n\n    all(Db, ViewName, Options) -\u003e\n        fold(Db, ViewName, fun collect_results/2, Options).\n\nThat's it. More documentation is coming soon.\n\n## Test it\n\n    $ ERL_FLAGS=\"-pa /path/to/couchc\" ./util/run -i\n    \n    Eshell V5.8.4  (abort with ^G)\n    1\u003e Apache CouchDB 1.2.0a-0cd6405-git (LogLevel=info) is starting.\n    Apache CouchDB has started. Time to relax.\n    [info] [\u003c0.36.0\u003e] Apache CouchDB has started on http://127.0.0.1:5984/\n\n    1\u003e couchc_test:test().\n    [info] [\u003c0.214.0\u003e] checkpointing view update at seq 2 for couchc_testdb _design/test\n    [info] [\u003c0.214.0\u003e] checkpointing view update at seq 3 for couchc_testdb _design/test\n    [info] [\u003c0.214.0\u003e] checkpointing view update at seq 4 for couchc_testdb _design/test\n    [info] [\u003c0.214.0\u003e] Shutting down view group server, monitored db is closing.\n      All 5 tests passed.\n    ok\n    2\u003e \n    \n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitc%2Fcouchc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenoitc%2Fcouchc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitc%2Fcouchc/lists"}