Fix possible typos in 6.3 (IndexedDB)

This commit is contained in:
Vse Mozhe Buty 2020-12-02 23:28:11 +02:00
parent e1a3f634a4
commit fd85fc5521

View file

@ -34,7 +34,7 @@ let openRequest = indexedDB.open(name, version);
We can have many databases with different names, but all of them exist within the current origin (domain/protocol/port). Different websites can't access each other's databases. We can have many databases with different names, but all of them exist within the current origin (domain/protocol/port). Different websites can't access each other's databases.
The call returns `openRequest` object, we should listen to events on it: The call returns `openRequest` object, we should listen to events on it:
- `success`: database is ready, there's the "database object" in `openRequest.result`, that we should use it for further calls. - `success`: database is ready, there's the "database object" in `openRequest.result`, we should use it for further calls.
- `error`: opening failed. - `error`: opening failed.
- `upgradeneeded`: database is ready, but its version is outdated (see below). - `upgradeneeded`: database is ready, but its version is outdated (see below).
@ -117,7 +117,7 @@ Let's say:
2. Then we rolled out an update, so our code is newer. 2. Then we rolled out an update, so our code is newer.
3. And then the same visitor opens our site in another tab. 3. And then the same visitor opens our site in another tab.
So there's a tab with an open connection to DB version `1`, while the second tab one attempts to update it to version `2` in its `upgradeneeded` handler. So there's a tab with an open connection to DB version `1`, while the second one attempts to update it to version `2` in its `upgradeneeded` handler.
The problem is that a database is shared between two tabs, as it's the same site, same origin. And it can't be both version `1` and `2`. To perform the update to version `2`, all connections to version 1 must be closed, including the one in the first tab. The problem is that a database is shared between two tabs, as it's the same site, same origin. And it can't be both version `1` and `2`. To perform the update to version `2`, all connections to version 1 must be closed, including the one in the first tab.
@ -153,7 +153,7 @@ openRequest.onblocked = function() {
// this event shouldn't trigger if we handle onversionchange correctly // this event shouldn't trigger if we handle onversionchange correctly
// it means that there's another open connection to same database // it means that there's another open connection to same database
// and it wasn't closed after db.onversionchange triggered for them // and it wasn't closed after db.onversionchange triggered for it
}; };
*/!* */!*
``` ```
@ -687,7 +687,7 @@ Whether there are more values matching the cursor or not -- `onsuccess` gets cal
In the example above the cursor was made for the object store. In the example above the cursor was made for the object store.
But we also can make a cursor over an index. As we remember, indexes allow to search by an object field. Cursors over indexes to precisely the same as over object stores -- they save memory by returning one value at a time. But we also can make a cursor over an index. As we remember, indexes allow to search by an object field. Cursors over indexes do precisely the same as over object stores -- they save memory by returning one value at a time.
For cursors over indexes, `cursor.key` is the index key (e.g. price), and we should use `cursor.primaryKey` property for the object key: For cursors over indexes, `cursor.key` is the index key (e.g. price), and we should use `cursor.primaryKey` property for the object key: