You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by gl...@apache.org on 2018/07/23 13:29:11 UTC

[couchdb-nano] branch issue98 updated: further documentation changes after feedback from @janl

This is an automated email from the ASF dual-hosted git repository.

glynnbird pushed a commit to branch issue98
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git


The following commit(s) were added to refs/heads/issue98 by this push:
     new 155c139  further documentation changes after feedback from @janl
155c139 is described below

commit 155c139f7dba06e631f5456c89a4c667727013c3
Author: Glynn Bird <gl...@gmail.com>
AuthorDate: Mon Jul 23 14:29:04 2018 +0100

    further documentation changes after feedback from @janl
---
 README.md           | 28 ++++++++++++++--------------
 migration_6_to_7.md |  5 ++++-
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/README.md b/README.md
index 7cc8d41..fe4ac98 100644
--- a/README.md
+++ b/README.md
@@ -144,7 +144,20 @@ The documentation will now follow the *Promises* style.
 ------------------
 
 
-A simple but complete example is:
+A simple but complete example in the [async/await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) style:
+
+```js
+async function asyncCall() {
+  await nano.db.destory('alice')
+  await nano.db.create('alice')
+  const alice = nano.use('alice')
+  const response = await alice.insert({ happy: true }, 'rabbit')
+  return response
+}
+asyncCall()
+```
+
+or in the raw Promises-style
 
 ```js
 const nano = require('nano')('http://localhost:5984');
@@ -161,19 +174,6 @@ nano.db.destory('alice').then((response) => {
 })
 ```
 
-or in the `async/await` style:
-
-```js
-async function asyncCall() {
-  await nano.db.destory('alice')
-  await nano.db.create('alice')
-  const alice = nano.use('alice')
-  const response = await alice.insert({ happy: true }, 'rabbit')
-  return response
-}
-asyncCall()
-```
-
 If you run either of these examples (after starting CouchDB) you will see:
 
 ```
diff --git a/migration_6_to_7.md b/migration_6_to_7.md
index 33d1f92..729b70b 100644
--- a/migration_6_to_7.md
+++ b/migration_6_to_7.md
@@ -18,6 +18,9 @@ In Nano 7:
 // Nano 7
 const db = nano.db.use('mydb')
 const x = await db.get('mydoc') 
+// the return value of db.get is a Promise, 
+// the 'await' operator waits for the Promise to resolve and 
+// x is your requested CouchDB object
 ```
 
 If you are not using the streaming properties of Nano 6's return value, you may not need to change any code at all. This document outlines the areas that have changed and what you need to do to your code.
@@ -67,7 +70,7 @@ db.get('mydoc').then((doc) => {
 })
 ```
 
-The Promise style of code lets you code sequences of asynchronou calls at the same level of indentation (the callback style forces you to indent further to the right with each call!):
+The Promise style of code lets you code sequences of asynchronous calls at the same level of indentation (the callback style forces you to indent further to the right with each call!):
 
 ```js
 db.get('mydoc').then((doc) => {