Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ mime.types
.rebar
*.plt
.idea
*.iml
*.im
*.crashdump
site/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2009-2016 (c) Benoît Chesneau <benoitc@e-engura.org>
2009-2025 (c) Benoit Chesneau

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
DOCKER?=docker
COMPOSE?=docker compose

.PHONY: docker-build docker-up docker-down docker-logs docker-test docker-shell
docs:
rebar3 ex_doc

docker-build:
$(COMPOSE) build

docker-up:
$(COMPOSE) up -d couchdb

docker-down:
$(COMPOSE) down -v

docker-logs:
$(COMPOSE) logs -f --tail=200

docker-test:
# Start CouchDB in the background
$(COMPOSE) up -d --build couchdb ; \
# Run tests as a one-off container, attach only to test output
$(COMPOSE) run --rm test ; \
status=$$? ; \
$(COMPOSE) down -v ; \
exit $$status

docker-shell:
$(COMPOSE) run --rm test bash
31 changes: 21 additions & 10 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
couchbeam NEWS
--------------

version 2.0.0 / 2025-09-03
--------------------------

- move from propos lists to maps for json
- remove JSX & Jiffy Usage for erlang/0TP 28.0+ json module
- View and changes streaming now use a simpler parser

** BREAKING CHANGE **

- move to maps, you will need to migrate your application to use them.
no backward compatibility is provided

version 1.7.1 / 2025-07-24
---------------------------

Expand Down Expand Up @@ -152,7 +164,7 @@ version 1.1.1 / 2014-11-11
- update to [hackney 0.15.0](https://github.com/benoitc/hackney/releases ),
improving performances and concurrency
- fix `couchbeam:doc_exists/2`(#116)
- fix `couchbeam:reply_att/1 (#114)
- fix `couchbeam:reply_att/1` (#114)


version 1.1.0 / 2014-10-28
Expand Down Expand Up @@ -239,10 +251,9 @@ version 0.10.0 / 2013-12-21
revisions
- add support of the [multipart
API](http://docs.couchdb.org/en/latest/api/document/common.html#efficient-multiple-attachments-retrieving) when fetching a doc: This change make
`couchbeam:open_doc/3` return a multipart response `{ok, {multipart,
Stream}}` when using the setting `attachments=true` option. A new option
{`accept. <<"multipart/mixed">>}" can also be used with the options
`open_revs` or `revs` to fetch the response as a multipart.
`couchbeam:open_doc/3` returns a multipart response `{ok, {multipart, Stream}}`
when using the `attachments=true` option. A new option `{accept, <<"multipart/mixed">>}`
can also be used with the options `open_revs` or `revs` to fetch the response as a multipart.
- bump the [hackney](http://github.com/benoitc/hackney) version to
**0.9.1** .

Expand All @@ -254,7 +265,7 @@ attachments or a doc wit all its revisions.
version 0.9.3 / 2013-12-07
--------------------------

- fix: `couchbeam:open_or_create_db/2'
- fix: couchbeam:open_or_create_db/2

version 0.9.2 / 2013-12-07
--------------------------
Expand All @@ -272,17 +283,17 @@ version 0.9.0 / 2013-12-05
This is a major release pre-1.0. API is now frozen and won't change much
until the version 1.0.

- replaced the use of `ibrowse` by `hackney` to handle HTTP connections
- replaced the use of ibrowse by hackney to handle HTTP connections
- new [streaming
API](https://github.com/benoitc/couchbeam#stream-view-results) in view
- breaking change: remobe
- breaking change: remove deprecated view API. Everything is now managed in the
[couch_view](https://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_view.md) module.
- replace `couchbeam_changes:stream` and `couchbeam_changes:fetch`
functions by `couchbeam_changes/follow` and `couchbeam_changes:follow_once`.
- replace 'couchbeam_changes:stream' and 'couchbeam_changes:fetch'
functions by 'couchbeam_changes/follow' and 'couchbeam_changes:follow_once'.
- breaking change: new attachment API
- new: JSX a pure erlang JSON encoder/decoder is now the default. Jiffy
can be set at the compilation by defining `WITH_JIFFY` in the Erlang
can be set at the compilation by defining 'WITH_JIFFY' in the Erlang
options.
- removed mochiweb dependency.

Expand Down
6 changes: 3 additions & 3 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Couchdbeam
----------
Couchbeam
---------

2009-2016 (c) Benoitît Chesneau <benoitc@e-engura.org>
2009-2025 (c) Benoit Chesneau

couchbeam is released under the MIT license. See the LICENSE file for the
complete license.
87 changes: 31 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Couchbeam - simple Apache CouchDB client library for Erlang applications #

Copyright (c) 2009-2025 Benoît Chesneau.
Copyright (c) 2009-2025 Benoit Chesneau.

__Version:__ 1.7.1

Expand All @@ -17,9 +17,7 @@ Couchbeam is a simple erlang library for [Barrel](https://barrel-db.org) or [Apa
- Stream changes feeds
- reduced memory usage
- fetch and send attachments in a streaming fashion
- by default use the JSX module to encode/decode JSON
- support [Jiffy](http://github.com/davisp/jiffy) a JSON encoder/decoder
in C.
- JSON encoding/decoding via Erlang/OTP stdlib `json` with maps

#### Useful modules are:

Expand Down Expand Up @@ -151,10 +149,10 @@ Make a new document:

```
erlang
Doc = {[
{<<"_id">>, <<"test">>},
{<<"content">>, <<"some text">>}
]}.
Doc = #{
<<"_id">> => <<"test">>,
<<"content">> => <<"some text">>
}.
```

And save it to the database:
Expand Down Expand Up @@ -201,18 +199,21 @@ Options = [include_docs],
{ok, AllDocs} = couchbeam_view:all(Db, Options).
```

Ex of results:
Example result (abridged):

```
erlang
{ok,[{[{<<"id">>,<<"7a0ce91d0d0c5e5b51e904d1ee3266a3">>},
{<<"key">>,<<"7a0ce91d0d0c5e5b51e904d1ee3266a3">>},
{<<"value">>,
{[{<<"rev">>,<<"15-15c0b3c4efa74f9a80d28ac040f18bdb">>}]}},
{<<"doc">>,
{[{<<"_id">>,<<"7a0ce91d0d0c5e5b51e904d1ee3266a3">>},
{<<"_rev">>,<<"15-15c0b3c4efa74f9a80d28ac040f18"...>>}]}}]},
]}.
{ok, [
#{
<<"id">> => <<"7a0ce91d0d0c5e5b51e904d1ee3266a3">>,
<<"key">> => <<"7a0ce91d0d0c5e5b51e904d1ee3266a3">>,
<<"value">> => #{<<"rev">> => <<"15-15c0b3c4efa74f9a80d28ac040f18bdb">>},
<<"doc">> => #{
<<"_id">> => <<"7a0ce91d0d0c5e5b51e904d1ee3266a3">>,
<<"_rev">> => <<"15-15c0b3c4efa74f9a80d28ac040f18"...>>
}
}
]}.
```

All functions to manipulate these results are in the `couchbeam_view` module.
Expand All @@ -238,21 +239,18 @@ Design doc are created like any documents:

```
erlang
DesignDoc = {[
{<<"_id">>, <<"_design/couchbeam">>},
{<<"language">>,<<"javascript">>},
{<<"views">>,
{[{<<"test">>,
{[{<<"map">>,
<<"function (doc) {\n if (doc.type == \"test\") {\n emit(doc._id, doc);\n}\n}">>
}]}
},{<<"test2">>,
{[{<<"map">>,
<<"function (doc) {\n if (doc.type == \"test2\") {\n emit(doc._id, null);\n}\n}">>
}]}
}]}
DesignDoc = #{
<<"_id">> => <<"_design/couchbeam">>,
<<"language">> => <<"javascript">>,
<<"views">> => #{
<<"test">> => #{
<<"map">> => <<"function (doc) {\n if (doc.type == \"test\") {\n emit(doc._id, doc);\n}\n}">>
},
<<"test2">> => #{
<<"map">> => <<"function (doc) {\n if (doc.type == \"test2\") {\n emit(doc._id, null);\n}\n}">>
}
]},
}
},
{ok, DesignDoc1} = couchbeam:save_doc(Db, DesignDoc).
```

Expand Down Expand Up @@ -320,7 +318,7 @@ To fetch an attachment:
{ok Att1} = couchbeam:fetch_attachment(Db, DocId, AttName).
```

You can use `couchbeam:stream_fetch_attachment/6` for the stream
You can use `couchbeam:stream_attachment/1` for the stream
fetch.

To delete an attachment:
Expand Down Expand Up @@ -378,7 +376,7 @@ for more info.
You can authenticate to the database or Apache CouchDB or RCOUCH server by filling
options to the Option list in `couchbeam:server_connection/4` for the
server or in `couchbeam:create_db/3`, `couchbeam:open_db/3`,
`couchbeam:wopen_or_create_db/3` functions.
`couchbeam:open_or_create_db/3` functions.

To set basic_auth on a server:

Expand All @@ -399,26 +397,3 @@ in the `couchbeam:server_connection/2` documentation.

For issues, comments or feedback please [create an
issue](http://github.com/benoitc/couchbeam/issues).


## Modules ##


<table width="100%" border="0" summary="list of modules">
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam.md" class="module">couchbeam</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_app.md" class="module">couchbeam_app</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_attachments.md" class="module">couchbeam_attachments</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_changes.md" class="module">couchbeam_changes</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_changes_stream.md" class="module">couchbeam_changes_stream</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_changes_sup.md" class="module">couchbeam_changes_sup</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_doc.md" class="module">couchbeam_doc</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_ejson.md" class="module">couchbeam_ejson</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_httpc.md" class="module">couchbeam_httpc</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_sup.md" class="module">couchbeam_sup</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_util.md" class="module">couchbeam_util</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_uuids.md" class="module">couchbeam_uuids</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_view.md" class="module">couchbeam_view</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_view_stream.md" class="module">couchbeam_view_stream</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/couchbeam_view_sup.md" class="module">couchbeam_view_sup</a></td></tr>
<tr><td><a href="http://github.com/benoitc/couchbeam/blob/master/doc/gen_changes.md" class="module">gen_changes</a></td></tr></table>

Loading
Loading