Skip to content

Commit c805077

Browse files
docs(generated): update examples (#923)
Generated SDK source code using: - Generator version 3.108.0 - Specification version 1.0.0-dev0.1.31 - Automation (cloudant-sdks) version 66d1dad
1 parent 0aad7a3 commit c805077

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

docs/Examples.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ except ApiException as ae:
5757
# 3. Create a document ================================================
5858
# Create a document object with "example" id
5959
example_doc_id = "example"
60-
# Setting `id` for the document is optional when "post_document"
61-
# function is used for CREATE. When `id` is not provided the server
60+
# Setting `_id` for the document is optional when "post_document"
61+
# function is used for CREATE. When `_id` is not provided the server
6262
# will generate one for your document.
63-
example_document: Document = Document(id=example_doc_id)
63+
example_document: Document = Document(_id=example_doc_id)
6464

6565
# Add "name" and "joined" fields to the document
6666
example_document.name = "Bob Smith"
@@ -84,22 +84,19 @@ create_document_response = client.put_document(
8484
"""
8585
# =====================================================================
8686

87-
# Keeping track of the revision number of the document object
88-
# is necessary for further UPDATE/DELETE operations:
89-
example_document.rev = create_document_response["rev"]
90-
print(f'You have created the document:\n{example_document}')
87+
response_body = json.dumps(create_document_response, indent=2)
88+
print(f'You have created the document. Response body:\n{response_body}')
9189
```
9290

9391
When you run the code, you see a result similar to the following output.
9492

9593
```text
9694
"orders" database created.
97-
You have created the document:
95+
You have created the document. Response body:
9896
{
99-
"_id": "example",
100-
"_rev": "1-1b403633540686aa32d013fda9041a5d",
101-
"name": "Bob Smith",
102-
"joined": "2019-01-24T10:42:99.000Z"
97+
"ok": true,
98+
"id": "example",
99+
"rev": "1-1b403633540686aa32d013fda9041a5d"
103100
}
104101
```
105102

@@ -155,14 +152,14 @@ print(f'Document retrieved from database:\n'
155152
When you run the code, you see a result similar to the following output.
156153

157154
```text
158-
Server Version: 2.1.1
155+
Server Version: 3.2.1
159156
Document count in "orders" database is 1.
160157
Document retrieved from database:
161158
{
162159
"_id": "example",
163160
"_rev": "1-1b403633540686aa32d013fda9041a5d",
164161
"name": "Bob Smith",
165-
"joined": "2019-01-24T10:42:99.000Z"
162+
"joined": "2019-01-24T10:42:59.000Z"
166163
}
167164
```
168165

@@ -253,7 +250,7 @@ try:
253250

254251
except ApiException as ae:
255252
if ae.status_code == 404:
256-
print('Cannot delete document because either ' +
253+
print('Cannot update document because either ' +
257254
f'"{example_db_name}" database or "{example_doc_id}" ' +
258255
'document was not found.')
259256
```
@@ -262,6 +259,7 @@ except ApiException as ae:
262259
When you run the code, you see a result similar to the following output.
263260

264261
```text
262+
You have updated the document:
265263
{
266264
"_id": "example",
267265
"_rev": "2-4e2178e85cffb32d38ba4e451f6ca376",
@@ -311,7 +309,7 @@ try:
311309
except ApiException as ae:
312310
if ae.status_code == 404:
313311
print('Cannot delete document because either ' +
314-
f'"{example_db_name}" database or "{example_doc_id}"' +
312+
f'"{example_db_name}" database or "{example_doc_id}" ' +
315313
'document was not found.')
316314
```
317315

0 commit comments

Comments
 (0)