@@ -5,6 +5,65 @@ has breaking API changes. Each section covers migrating from one major version
55to another. The section titles state the versions between which the change was
66made.
77
8+ ## 3.x → 4.x
9+
10+ [ Apache CouchDB Nano] ( https://www.npmjs.com/package/nano ) version 7 used in
11+ ` nodejs-cloudant ` 3.x had an API error that allowed specifying a callback when
12+ using ` *AsStream ` functions. Using a callback with the ` request ` object caused a
13+ ` Buffer ` allocation attempt for the entire response size, which would fail for
14+ large streams. The correct approach is to use event listeners on the response
15+ stream.
16+
17+ To prevent incorrect usage the option of providing a callback was removed from
18+ the Apache CouchDB Nano API in version 8 and consequently nodejs-cloudant 4.x.
19+ Consumers of the ` *AsStream ` functions using callbacks need to adapt their code
20+ to use event listeners instead. For example:
21+
22+ ``` js
23+ cloudant .db .listAsStream (function (error , response , body ) {
24+ if (error) {
25+ console .log (' ERROR' );
26+ } else {
27+ console .log (' DONE' );
28+ }
29+ }).pipe (process .stdout );
30+ ```
31+
32+ may be replaced with:
33+
34+ ``` js
35+ cloudant .db .listAsStream ()
36+ .on (' error' , function (error ) {
37+ console .log (' ERROR' );
38+ })
39+ .on (' end' , function (error ) {
40+ console .log (' DONE' );
41+ })
42+ .pipe (process .stdout );
43+ ```
44+
45+ ## 2.x → 3.x
46+
47+ We've upgraded our [ nano] ( https://www.npmjs.com/package/nano ) dependency. This
48+ means all return types are now a ` Promise ` (except for the ` ...AsStream `
49+ functions). The ` promise ` plugin is no longer required. It is silently ignored
50+ when specified in the client configuration.
51+
52+ Example:
53+ ``` js
54+ var cloudant = new Cloudant ({ url: myUrl, plugins: [ ' retry' ] });
55+
56+ // Lists all the databases.
57+ cloudant .db .list ().then ((dbs ) => {
58+ dbs .forEach ((db ) => {
59+ console .log (db);
60+ });
61+ }).catch ((err ) => { console .log (err); });
62+ ```
63+
64+ Nano is responsible for resolving or rejecting all promises. Any errors thrown
65+ are created from within Nano. The old ` CloudantError ` type no longer exists.
66+
867## 1.x → 2.x
968
1069This change introduces multiple plugin support by using a request interceptor
@@ -49,25 +108,3 @@ var cloudant = new Cloudant({ url: myUrl, plugins: [] });
49108
50109Finally, the ` promise ` plugin now throws a ` CloudantError ` (extended from
51110` Error ` ) rather than a ` string ` which was considered bad practice.
52-
53- ## 2.x → 3.x
54-
55- We've upgraded our [ nano] ( https://www.npmjs.com/package/nano ) dependency. This
56- means all return types are now a ` Promise ` (except for the ` ...AsStream `
57- functions). The ` promise ` plugin is no longer required. It is silently ignored
58- when specified in the client configuration.
59-
60- Example:
61- ``` js
62- var cloudant = new Cloudant ({ url: myUrl, plugins: [ ' retry' ] });
63-
64- // Lists all the databases.
65- cloudant .db .list ().then ((dbs ) => {
66- dbs .forEach ((db ) => {
67- console .log (db);
68- });
69- }).catch ((err ) => { console .log (err); });
70- ```
71-
72- Nano is responsible for resolving or rejecting all promises. Any errors thrown
73- are created from within Nano. The old ` CloudantError ` type no longer exists.
0 commit comments