Skip to content

Commit 9994f85

Browse files
authored
allow fetch to return errors as well as successes - fixes issue #203 (#204)
1 parent ee50585 commit 9994f85

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/nano.d.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ declare namespace nano {
189189
callback?: Callback<DocumentFetchResponse<D>>
190190
): Promise<DocumentFetchResponse<D>>;
191191
// http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs
192-
fetchRevs(docnames: BulkFetchDocsWrapper, callback?: Callback<DocumentFetchRevsResponse>): Promise<DocumentFetchRevsResponse>;
192+
fetchRevs(docnames: BulkFetchDocsWrapper, callback?: Callback<DocumentFetchRevsResponse<D>>): Promise<DocumentFetchRevsResponse<D>>;
193193
// http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs
194194
fetchRevs(
195195
docnames: BulkFetchDocsWrapper,
196196
params: DocumentFetchParams,
197-
callback?: Callback<DocumentFetchRevsResponse>
198-
): Promise<DocumentFetchRevsResponse>;
197+
callback?: Callback<DocumentFetchRevsResponse<D>>
198+
): Promise<DocumentFetchRevsResponse<D>>;
199199
// http://docs.couchdb.org/en/latest/api/database/find.html#db-index
200200
createIndex(indexDef: CreateIndexRequest,
201201
callback?: Callback<CreateIndexResponse>
@@ -1040,22 +1040,25 @@ declare namespace nano {
10401040
start_key_doc_id?: string;
10411041
update_seq?: boolean;
10421042
}
1043+
interface DocumentLookupFailure {
1044+
key: string;
1045+
error: string;
1046+
}
10431047

10441048
interface DocumentFetchResponse<D> {
10451049
offset: number;
1046-
rows: Array<DocumentResponseRow<D>>;
1050+
rows: Array<DocumentResponseRow<D> | DocumentLookupFailure>;
10471051
total_rows: number;
10481052
update_seq?: number;
10491053
}
10501054

1051-
interface DocumentFetchRevsResponse {
1055+
interface DocumentFetchRevsResponse<D> {
10521056
offset: number;
1053-
rows: DocumentResponseRowMeta[];
1057+
rows: Array<DocumentResponseRow<D> | DocumentLookupFailure>;
10541058
total_rows: number;
10551059
update_seq?: number;
10561060
}
10571061

1058-
10591062
interface DocumentSearchResponse<V> {
10601063

10611064
// Array of search results

0 commit comments

Comments
 (0)