Skip to content

Commit f270bd1

Browse files
author
alxndrsn
committed
Merge remote-tracking branch 'upstream/master' into non-objects
2 parents aeb723d + 16b6c07 commit f270bd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+239
-183
lines changed

docs/_guides/attachments.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ db.put({
116116
}).then(function () {
117117
return db.getAttachment('meowth', 'meowth.png');
118118
}).then(function (blob) {
119-
var url = URL.createObjectURL(blob);
120-
var img = document.createElement('img');
119+
const url = URL.createObjectURL(blob);
120+
const img = document.createElement('img');
121121
img.src = url;
122122
document.body.appendChild(img);
123123
}).catch(function (err) {
@@ -150,16 +150,16 @@ For instance, we can read the image data from an `<img>` tag using a `canvas` el
150150

151151
```js
152152
function convertImgToBlob(img, callback) {
153-
var canvas = document.createElement('canvas');
154-
var context = canvas.getContext('2d');
153+
const canvas = document.createElement('canvas');
154+
const context = canvas.getContext('2d');
155155
context.drawImage(img, 0, 0);
156156

157157
// Warning: toBlob() isn't supported by every browser.
158158
// You may want to use blob-util.
159159
canvas.toBlob(callback, 'image/png');
160160
}
161161

162-
var catImage = document.getElementById('cat');
162+
const catImage = document.getElementById('cat');
163163
convertImgToBlob(catImage, function (blob) {
164164
db.putAttachment('meowth', 'meowth.png', blob, 'image/png').then(function () {
165165
return db.get('meowth', {attachments: true});
@@ -196,9 +196,9 @@ Here is an example of allowing a user to choose a file from their filesystem:
196196
And then "uploading" that file directly into PouchDB:
197197

198198
```js
199-
var input = document.querySelector('input');
199+
const input = document.querySelector('input');
200200
input.addEventListener('change', function () {
201-
var file = input.files[0]; // file is a Blob
201+
const file = input.files[0]; // file is a Blob
202202

203203
db.put({
204204
_id: 'mydoc',
@@ -285,7 +285,7 @@ The other "read" APIs, such as `get()`, `allDocs()`, `changes()`, and `query()`
285285
Blobs have their own `type`, but there is also a `content_type` that you specify when you store it in PouchDB:
286286

287287
```js
288-
var myBlob = new Blob(['I am plain text!'], {type: 'text/plain'});
288+
const myBlob = new Blob(['I am plain text!'], {type: 'text/plain'});
289289
console.log(myBlob.type); // 'text/plain'
290290

291291
db.put({

docs/_guides/changes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ Also notice the option `{include_docs: true}`. By default, the documents themsel
4343
If you expect this to be a very large number of changes, you can also use the `limit` option to do pagination:
4444

4545
```js
46-
var pageSize = 10;
47-
var lastSeq = 0;
46+
const pageSize = 10;
47+
let lastSeq = 0;
4848
function fetchNextPage() {
4949
return db.changes({
5050
since: lastSeq,

docs/_guides/compact-and-destroy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ However, if that's not a concern, then compaction is a harmless operation. In fa
5252
If you really want to go all-in on compaction, then you can even put your database in `auto_compaction` mode. This means that it will automatically perform a `compact()` operation after every write.
5353

5454
```js
55-
var db = new PouchDB('mydb', {auto_compaction: true});
55+
const db = new PouchDB('mydb', {auto_compaction: true});
5656
db.put({_id: 'foo', version: 1}).then(function () {
5757
return db.get('foo');
5858
}).then(function (doc) {

docs/_guides/conflicts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ In CouchDB, conflicts can occur in two places: immediately, when you try to comm
2424
**Immediate conflicts** can occur with any API that takes a `rev` or a document with `_rev` as input &ndash; `put()`, `post()`, `remove()`, `bulkDocs()`, and `putAttachment()`. They manifest as a `409` (conflict) error:
2525

2626
```js
27-
var myDoc = {
27+
const myDoc = {
2828
_id: 'someid',
2929
_rev: '1-somerev'
3030
};

docs/_guides/databases.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PouchDB databases come in two flavors: local and remote.
1212
To create a local database, you simply call `new PouchDB` and give it a name:
1313

1414
```js
15-
var db = new PouchDB('kittens');
15+
const db = new PouchDB('kittens');
1616
```
1717

1818
You can see a **[live example](http://bl.ocks.org/nolanlawson/bddac54b92c2d8d39241)** of this code.
@@ -37,7 +37,7 @@ Now the site is up and running at <a href='http://localhost:8000'>http://localho
3737
To create a remote database, you call `new PouchDB` and give it a path to a database in CouchDB.
3838

3939
```js
40-
var db = new PouchDB('http://localhost:5984/kittens');
40+
const db = new PouchDB('http://localhost:5984/kittens');
4141
```
4242

4343
{% include alert/start.html variant="info" %}

docs/_guides/documents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ We'll discuss these concepts later on.
6464
To store a document, you simply `put` it:
6565

6666
```js
67-
var doc = {
67+
const doc = {
6868
"_id": "mittens",
6969
"name": "Mittens",
7070
"occupation": "kitten",

docs/_guides/mango-queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ If you are using Node, Browserify, Webpack, Rollup, etc., then you can install i
3636
Then in code:
3737

3838
```js
39-
var PouchDB = require('pouchdb');
39+
const PouchDB = require('pouchdb');
4040
PouchDB.plugin(require('pouchdb-find'));
4141
```
4242

docs/_guides/queries.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ First, you create a **design document**, which describes the `map` function you
5050
```js
5151
// document that tells PouchDB/CouchDB
5252
// to build up an index on doc.name
53-
var ddoc = {
53+
const ddoc = {
5454
_id: '_design/my_index',
5555
views: {
5656
by_name: {
@@ -203,7 +203,7 @@ As for _reduce_ functions, there are a few handy built-ins that do aggregate ope
203203

204204
```js
205205
// emit the first letter of each pokemon's name
206-
var myMapReduceFun = {
206+
const myMapReduceFun = {
207207
map: function (doc) {
208208
emit(doc.name.charAt(0));
209209
},

docs/_guides/replication.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ In this way, CouchDB replication "just works."
4242
As you already know, you can create either local PouchDBs:
4343

4444
```js
45-
var localDB = new PouchDB('mylocaldb')
45+
const localDB = new PouchDB('mylocaldb')
4646
```
4747

4848
or remote PouchDBs:
4949

5050
```js
51-
var remoteDB = new PouchDB('http://localhost:5984/myremotedb')
51+
const remoteDB = new PouchDB('http://localhost:5984/myremotedb')
5252
```
5353

5454
This pattern comes in handy when you want to share data between the two.
@@ -132,7 +132,7 @@ This is ideal for scenarios where the user may be flitting in and out of connect
132132
Sometimes, you may want to manually cancel replication &ndash; for instance, because the user logged out. You can do so by calling `cancel()` and then waiting for the `'complete'` event:
133133

134134
```js
135-
var syncHandler = localDB.sync(remoteDB, {
135+
const syncHandler = localDB.sync(remoteDB, {
136136
live: true,
137137
retry: true
138138
});
@@ -147,7 +147,7 @@ syncHandler.cancel(); // <-- this cancels it
147147
The `replicate` API also supports canceling:
148148

149149
```js
150-
var replicationHandler = localDB.replicate.to(remoteDB, {
150+
const replicationHandler = localDB.replicate.to(remoteDB, {
151151
live: true,
152152
retry: true
153153
});

docs/_guides/setup-pouchdb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $ npm install pouchdb
6363
Then in your JavaScript:
6464

6565
```js
66-
var PouchDB = require('pouchdb');
66+
const PouchDB = require('pouchdb');
6767
```
6868

6969
{% include anchor.html title="With TypeScript" hash="typescript" %}

0 commit comments

Comments
 (0)