diff --git a/6-data-storage/03-indexeddb/article.md b/6-data-storage/03-indexeddb/article.md index af39d2c4..53635c20 100644 --- a/6-data-storage/03-indexeddb/article.md +++ b/6-data-storage/03-indexeddb/article.md @@ -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. 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. - `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. 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. @@ -153,7 +153,7 @@ openRequest.onblocked = function() { // this event shouldn't trigger if we handle onversionchange correctly // 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. -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: