@@ -355,7 +355,9 @@ nano.db.list().then((body) => {
355
355
Lists all the CouchDB databases as a stream:
356
356
357
357
``` js
358
- nano .db .list ().pipe (process .stdout );
358
+ nano .db .listAsStream ()
359
+ .on (' error' , (e ) => console .error (' error' , e))
360
+ .pipe (process .stdout );
359
361
```
360
362
361
363
### nano.db.compact(name, [ designname] , [ callback] )
@@ -623,7 +625,9 @@ alice.list({include_docs: true}).then((body) => {
623
625
List all the docs in the database as a stream.
624
626
625
627
``` js
626
- alice .list ().pipe (process .stdout )
628
+ alice .listAsStream ()
629
+ .on (' error' , (e ) => console .error (' error' , e))
630
+ .pipe (process .stdout )
627
631
```
628
632
629
633
### db.fetch(docnames, [ params] , [ callback] )
@@ -881,10 +885,14 @@ Fetch documents from a partition as a stream:
881
885
882
886
``` js
883
887
// fetch document id/revs from a partition
884
- nano .db .partitionedListAsStream (' canidae' ).pipe (process .stdout )
888
+ nano .db .partitionedListAsStream (' canidae' )
889
+ .on (' error' , (e ) => console .error (' error' , e))
890
+ .pipe (process .stdout )
885
891
886
892
// add document bodies but limit size of response
887
- nano .db .partitionedListAsStream (' canidae' , { include_docs: true , limit: 5 }).pipe (process .stdout )
893
+ nano .db .partitionedListAsStream (' canidae' , { include_docs: true , limit: 5 })
894
+ .on (' error' , (e ) => console .error (' error' , e))
895
+ .pipe (process .stdout )
888
896
```
889
897
890
898
### db.partitionedFind(partitionKey, query, [ params] )
@@ -902,7 +910,9 @@ Query documents from a partition by supplying a Mango selector as a stream:
902
910
903
911
``` js
904
912
// find document whose name is 'wolf' in the 'canidae' partition
905
- db .partitionedFindAsStream (' canidae' , { ' selector' : { ' name' : ' Wolf' }}).pipe (process .stdout )
913
+ db .partitionedFindAsStream (' canidae' , { ' selector' : { ' name' : ' Wolf' }})
914
+ .on (' error' , (e ) => console .error (' error' , e))
915
+ .pipe (process .stdout )
906
916
```
907
917
908
918
### db.partitionedSearch(partitionKey, designName, searchName, params, [ callback] )
@@ -925,7 +935,9 @@ Search documents from a partition by supplying a Lucene query as a stream:
925
935
const params = {
926
936
q: ' name:\' Wolf\' '
927
937
}
928
- db .partitionedSearchAsStream (' canidae' , ' search-ddoc' , ' search-index' , params).pipe (process .stdout )
938
+ db .partitionedSearchAsStream (' canidae' , ' search-ddoc' , ' search-index' , params)
939
+ .on (' error' , (e ) => console .error (' error' , e))
940
+ .pipe (process .stdout )
929
941
// { total_rows: ... , bookmark: ..., rows: [ ...] }
930
942
```
931
943
@@ -953,7 +965,9 @@ const params = {
953
965
endkey: ' b' ,
954
966
limit: 1
955
967
}
956
- db .partitionedView (' canidae' , ' view-ddoc' , ' view-name' , params).pipe (process .stdout )
968
+ db .partitionedViewAsStream (' canidae' , ' view-ddoc' , ' view-name' , params)
969
+ .on (' error' , (e ) => console .error (' error' , e))
970
+ .pipe (process .stdout )
957
971
// { rows: [ { key: ... , value: [Object] } ] }
958
972
```
959
973
@@ -1031,7 +1045,9 @@ alice.attachment.get('rabbit', 'rabbit.png').then((body) => {
1031
1045
``` js
1032
1046
const fs = require (' fs' );
1033
1047
1034
- alice .attachment .getAsStream (' rabbit' , ' rabbit.png' ).pipe (fs .createWriteStream (' rabbit.png' ));
1048
+ alice .attachment .getAsStream (' rabbit' , ' rabbit.png' )
1049
+ .on (' error' , (e ) => console .error (' error' , e))
1050
+ .pipe (fs .createWriteStream (' rabbit.png' ));
1035
1051
```
1036
1052
1037
1053
### db.attachment.destroy(docname, attname, [ params] , [ callback] )
@@ -1100,7 +1116,9 @@ alice.view('characters', 'happy_ones', { include_docs: true }).then((body) => {
1100
1116
Same as ` db.view ` but returns a stream:
1101
1117
1102
1118
``` js
1103
- alice .view (' characters' , ' happy_ones' , {reduce: false }).pipe (process .stdout );
1119
+ alice .viewAsStream (' characters' , ' happy_ones' , {reduce: false })
1120
+ .on (' error' , (e ) => console .error (' error' , e))
1121
+ .pipe (process .stdout );
1104
1122
```
1105
1123
1106
1124
### db.viewWithList(designname, viewname, listname, [ params] , [ callback] )
@@ -1227,7 +1245,9 @@ const q = {
1227
1245
fields: [ " name" , " age" , " tags" , " url" ],
1228
1246
limit: 50
1229
1247
};
1230
- alice .findAsStream (q).pipe (process .stdout );
1248
+ alice .findAsStream (q)
1249
+ .on (' error' , (e ) => console .error (' error' , e))
1250
+ .pipe (process .stdout );
1231
1251
```
1232
1252
1233
1253
## using cookie authentication
@@ -1307,7 +1327,9 @@ You can pipe the return values of certain nano functions like other stream. For
1307
1327
const fs = require (' fs' );
1308
1328
const nano = require (' nano' )(' http://127.0.0.1:5984/' );
1309
1329
const alice = nano .use (' alice' );
1310
- alice .attachment .getAsStream (' rabbit' , ' picture.png' ).pipe (fs .createWriteStream (' /tmp/rabbit.png' ));
1330
+ alice .attachment .getAsStream (' rabbit' , ' picture.png' )
1331
+ .on (' error' , (e ) => console .error (' error' , e))
1332
+ .pipe (fs .createWriteStream (' /tmp/rabbit.png' ));
1311
1333
` ` `
1312
1334
1313
1335
then open ` / tmp/ rabbit .png ` and you will see the rabbit picture.
0 commit comments