Skip to content

Commit fb2c5c5

Browse files
author
Veronika Matyus
committed
Add stream example notes
1 parent 1807769 commit fb2c5c5

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

test/examples/src/js/UpdateDoc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ const updateDoc = async () => {
3636
})
3737
).result;
3838

39+
// Note: for byte response (Output Stream) use:
40+
// const documentAsStream = (
41+
// await client.getDocumentAsStream({
42+
// docId: 'example',
43+
// db: exampleDbName,
44+
// })
45+
// ).result;
46+
3947
// Add Bob Smith's address to the document
4048
document.address = '19 Front Street, Darlington, DL5 1TY';
4149

@@ -50,6 +58,14 @@ const updateDoc = async () => {
5058
})
5159
).result.rev;
5260

61+
// Note: for byte request (Input Stream) use:
62+
// document._rev = (
63+
// await client.postDocument({
64+
// db: exampleDbName,
65+
// document: inputStream,
66+
// })
67+
// ).result.rev;
68+
5369
console.log(
5470
'You have updated the document:\n' + JSON.stringify(document, null, 2)
5571
);

test/examples/src/ts/UpdateDoc.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ const getDocParams: CloudantV1.GetDocumentParams = {
3535
db: exampleDbName,
3636
};
3737

38+
// Note: for byte response (Output Stream) use:
39+
// const getdocAsStreamParam: CloudantV1.GetDocumentAsStreamParams = {
40+
// docId: 'example',
41+
// db: exampleDbName,
42+
// };
43+
// client
44+
// .getDocumentAsStream(getdocAsStreamParam)
45+
// .then((outputStream) => {});
46+
3847
client
3948
.getDocument(getDocParams)
4049
.then((docResult) => {
@@ -48,13 +57,19 @@ client
4857
delete document.joined;
4958

5059
// Update the document in the database
51-
client.postDocument({ db: exampleDbName, document }).then((res) => {
52-
// Keeping track with the revision number of the document object:
53-
document._rev = res.result.rev;
54-
console.log(
55-
'You have updated the document:\n' + JSON.stringify(document, null, 2)
56-
);
57-
});
60+
client
61+
.postDocument({ db: exampleDbName, document })
62+
// Note: for byte request (Input Stream) use:
63+
// .postDocument(
64+
// {db: exampleDbName, documentAsStream}
65+
// )
66+
.then((res) => {
67+
// Keeping track with the revision number of the document object:
68+
document._rev = res.result.rev;
69+
console.log(
70+
'You have updated the document:\n' + JSON.stringify(document, null, 2)
71+
);
72+
});
5873
})
5974
.catch((err) => {
6075
if (err.code === 404) {

0 commit comments

Comments
 (0)