1. 序論
~UAは、~web~appの~off-line~data要件を充足するため,多数の~objを局所に格納する必要がある。 `WEBSTORAGE$r は、一連の[ ~keyと対応する値 ]の~pairを格納するために有用ではあるが、[ ~keyを~~一定の順序で検索取得する/ 多数の値にわたり効率的に探索する/ 一つの~keyに対し複合的な値を格納する ]方法は 供していない。 ◎ User agents need to store large numbers of objects locally in order to satisfy off-line data requirements of Web applications. [WEBSTORAGE] is useful for storing pairs of keys and their corresponding values. However, it does not provide in-order retrieval of keys, efficient searching over values, or storage of duplicate values for a key.
この仕様は、[ 大多数の洗練された~query処理器の心臓部である,高度な { ~key: 値 } ~data管理 ]を遂行する~APIを供する — ~txに基づく~dbを利用して,一連の[ ~keyと(~keyごとに一つ以上の)対応する値 ]を格納し,各~keyを決定的 順序で走査する手段を供することにより。 これは、永続的 B-tree ~data構造を利用して実装されることが多い — それは、挿入と削除に加えて,大量の~data~recordを~~一定の順序で走査するときにも効率的であると考えられているので。 ◎ This specification provides a concrete API to perform advanced key-value data management that is at the heart of most sophisticated query processors. It does so by using transactional databases to store keys and their corresponding values (one or more per key), and providing a means of traversing keys in a deterministic order. This is often implemented through the use of persistent B-tree data structures that are considered efficient for insertion and deletion as well as in-order traversal of very large numbers of data records.
【この訳に固有の表記規約】
( この節の表記規約は、この仕様が課す要件(〜し~MUST)を集約するものでもある。 )
この訳に利用される ~LET, ~IF, ~THROW, ~Assert 等々の意味や定義の詳細は,~SYMBOL_DEF_REFを~~参照( ~THROW の実行制御には暗黙的な,例外の再~投出-も含められていることに注意)。
加えて、次の記法も用いる:
- %演算 ?
- ~algoの中で %演算 を呼出す所の末尾に付与される記号 ? は、その %演算 から例外が投出され得ることを表す(一種の ~Assert )。
- これ°
- 各種~APIの定義における,太字で記された語 “此れ” は、 `DOM$r にて定義される 文脈~obj の略記である。 すなわち、論の対象の~IDL~interface~memberが~accessされている,当の~platform~obj(その~IDL~interfaceを実装する~obj ), または それを内部的に表現する抽象~obj(仕様の~modelにて定義される~obj)の~instanceを指す(この対応関係は,常に一対一なので、同一視する)。
- ↗(`~access先@)
- ~APIに公開される一部の型の~objは、ある型の抽象~objへの~accessを間接的に供するものとして定義される(具体的には、次項 “`専属する$” の図式に示される)。 %O がそのような型の~instanceであるとき、 %O を通して~accessされる抽象~objは, %O↗ とも記される。 %O から %O↗ への対応関係は、一般に多対一になることに注意。 また、 %O に対する %O↗ が別の~instanceに変わることは,決してない。
- %O は、ある時点を過ぎて以降, %O↗ に~accessできなくなることもある — %O↗ が %O よりも先に破壊された / %O↗ への~accessが “~closeされた” ときなど。 そうなったとしても、 %O↗ が持つ~propを反映するような, %O が持つ~IDL属性には、その `値を保持し続ける@ ものもある。 そのような属性は、[ %O↗ を~access先とする別の~objを通して %O↗ に変更が加えられた ]としても,元の属性~値を保つ。
- `専属する@
-
一部の型の~obj間には、 “専属する” という語で,その結び付けの関係が表記される。 ある型 %A の~instance %a が,別の型 %B の~instance %b に`専属する$という関係には、一般に,次が含意される:
- %a は、自身が存在し続ける限り, %b 以外の型 %B の~instanceには`専属しない$。
- %a が存在し続ける限り, %b も存在し続ける( %b が破壊される時点で, %a も破壊される)。
ある~instanceに`専属する$ような~instanceは,一般に複数 存在し得る。
- この専属するという関係は,同じ型の~instance間で定義されたり, 循環することは決してないので、推移的に拡張して利用される。 例えば %b が また別の型 %C の~instance %c に`専属する$とき、 “%a が`専属する$ %C ~obj” という記述は、 %c を指すことになる。
-
次の図式に、この関係を持つ, および 上述の~accessを供する関係を持つような,各種~objを要約する:
上向き矢印 “↑” を挟んだ下の~objが,上の~objに`専属する$。 斜め矢印 “↗” を挟んだ右の~objが,左の~objを通して~accessされる。 `生成元$ ↑ `接続$( `IDBDatabase$I ) ↗ `~db$ ↑ `~tx$( `IDBTransaction$I ) ↑ ↑ `保管庫~handle$( `IDBObjectStore$I ) ↗ `保管庫$ ↑ ↑ `索引~handle$( `IDBIndex$I ) ↗ `索引$ -
これらの型の~obj~instanceたちは、常に,次の可換性と一意性の要件を満たさ~MUST:
- `可換性@
-
上の図式は `可換^_ になる。 すなわち:
- どの`保管庫~handle$ %H に対しても ⇒ ( %H が`専属する$`接続$ ) ↗ ~EQ ( %H↗ が`専属する$`~db$ )
- どの`索引~handle$ %H に対しても ⇒ ( %H が`専属する$`保管庫~handle$ ) ↗ ~EQ ( %H↗ が`専属する$`保管庫$ )
- `一意性@
- 2 つの`保管庫~handle$(または 2 つの`索引~handle$) %H1, %H2 が与えられたとき ⇒ [ %H1↗, %H2↗ は,同じ~instanceに`専属する$ ]~AND[ %H1↗ ~EQ %H2↗ ]ならば, %H1 ~EQ %H2 になる。
この要件の目的においては、 %H↗, %H1↗, %H2↗ は、破壊されて以降も,他と区別できる個としては(何ら~accessできる実体はないが)存在し続けるとする。
- 所与の型の~obj~instanceが[ 作成される/取得される ]ときに[ どの~instanceに`専属する$, あるいは どの~instanceを`~access先$にする ]ようにされるか,については、上述の要件を満たすように,当の~objを[ 作成する/取得する ]~APIの記述にて定義される。
- ε
-
記号 ε は、存在しないことを表す,他のいかなる値とも異なる仮想の定数~値である:
- 各種~手続きの引数がとる値 ε は、その手続きの呼出時に,引数が省略された(または 手続きの引数に明示的に ε が渡された)ことを表す。
-
各種~API~methodの引数のうち,[ WebIDL `WEBIDL$r において、省略-時には,特殊~値 “missing” と解釈される引数 ]がとる値 ε は、その~methodの呼出時に,引数が省略されたことを表す — 具体的には、~IDLにて次をすべて満たすように定義された引数:
- 省略可能( "`optional^c" が付与されている)
-
既定~値を持たない( "
=%既定~値
" が付与されていない) - 辞書~型でない
- (この仕様には現れないが,) 可変個でない( "`...^c" が付与されていない)
ECMAScript `undefined^js 値がこの種の引数に明示的に渡された場合、 WebIDL の~~規定に従って,省略されたものと見なされる(したがって ε になる)。 他の引数に対する `undefined^js は、[ 既定~値があれば その値 / 無ければ `undefined^js を表現する特別な~IDL object 値 ]に解釈されることになる(したがって ε でない)。 省略可能でない引数が省略された場合、 WebIDL の~~規定に従って,単に `TypeError$js が投出される。 省略可能な辞書~型の引数が省略された場合、その型の空の辞書が指定されたものと見なされる。
-
他の所では,単に存在しないことを表す。 例えば:
- ある~prop %x を持つこともあれば持たないこともある抽象~obj %Y に対し,[ %Y の %x ~EQ ε ]という記述は、[ %Y は %x を持たない ]ことを意味する。
- 所与の条件を満たす何かとして定義されたものは、そのような条件を満たすものが存在しないときには、値 ε をとる(例えば、与えられた~listの “最初の要素” として定義された変数は、~listが空ならば値 ε をとる)。
- ( この記号を導入した目的は、~APIに現れるふるまいと内部処理~modelとの境界を明確化すること,および 記述を形式化して簡潔に記すことにある。 )
2. 各種~構成子
`名前@ は、`~DS$に等価な文字列である。 すなわち、空~文字列も含め,任意の長さの任意の~16-bit符号単位~列になり得る。 `名前$は常に不透明な~16-bit符号単位~列として比較される。 ◎ A name is a string equivalent to a DOMString; that is, an arbitrary sequence of 16-bit code units of any length, including the empty string. Names are always compared as opaque sequences of 16-bit code units.
注記: その~~結果,`名前$の比較では、文字大小のみならず,~Unicode~textにおける他の小さな差異 — 正規化形, 制御文字の有無, その他 — も区別される。 `Charmod-Norm$r ◎ As a result, name comparison is sensitive to variations in case as well as other minor variations such as normalization form, the inclusion or omission of controls, and other variations in Unicode text. [Charmod-Norm]
利用する蓄積の仕組みの下では~supportされない名前に対しては、実装は,~escapingに類する仕組みを利用して 格納できる名前に~~対応付けれる。 ◎ If an implementation uses a storage mechanism which does not support arbitrary strings, the implementation can use an escaping mechanism or something similar to map the provided name to a string that it can store.
`整列-済み名前~list@ は、~16-bit符号単位による昇順に整列された`名前$たちからなる~listである。 ◎ A sorted name list is a list containing names sorted in ascending order by 16-bit code unit.
これは、 `String$js からなる `Array$js ~obj上の `Array.prototype.sort^c に合致する。 この順序付けは、各~文字列~内の~16-bit符号単位どうしを比較するための[ 高効率で, 一貫する, 決定的な,整列-順序 ]を与える。 この整列-は、~alphabet順その他 どの字句的~順序にも — 特に,代用対で表現される符号位置に対しては — 合致しない。 ◎ This matches the Array.prototype.sort on an Array of Strings. This ordering compares the 16-bit code units in each string, producing a highly efficient, consistent, and deterministic sort order. The resulting list will not match any particular alphabet or lexicographical order, particularly for code points represented by a surrogate pair.
2.1. ~db
各 `生成元$には、 0 個~以上の`~db$が結付けられる — `~db$は,その生成元に`専属する$。
各 `~db@ は,自身に格納される~dataを保持する, 0 個~以上の`保管庫$からなる。 各`~db$ %~db は、次のものを持つ:
◎ Each origin has an associated set of databases. A database has zero or more object stores which hold the data stored in the database.- `名前@db
- 特定の`生成元$の中で, %~db を一意に識別する`名前$であり、 %~db が存続する間 変わらない。 ◎ A database has a name which identifies it within a specific origin. The name is a name, and stays constant for the lifetime of the database.
- 【 過去にどの名前の~dbを作成したか調べる~APIは(現時点では)用意されてない( issue 31 )。 名前を忘れると不味いことになる。 (逆に言えば、利用者~scriptは,~site作者からは見えない独自の~dbを作成できることになる。) 】
- `~version@db
- %~db の~versionを表現する非負~整数。 %~db 作成-時の`~version$dbは, 0 である。 ◎ A database has a version. When a database is first created, its version is 0 (zero).
- 【 %~db の作成-時には,自動的に`昇格~tx$が生じるので、実質的には 1 (以上)として公開される — そのときに~errorが生じない限り。 】
- 注記: `~db$が同時に持ち得る~versionは一つだけである — 同時に複数の~versionを持つような~dbは存在し得ない。 ~versionは、`昇格~tx$を通してのみ変更し得る。 ◎ Each database has one version at a time; a database can’t exist in multiple versions at once. The only way to change the version is using an upgrade transaction.
- `昇格~tx@db
- `昇格~tx$または ε (存在しない) — 初期~時は ε とする。 ◎ A database has at most one associated upgrade transaction, which is either null or an upgrade transaction, and is initially null.
- 【 所与の時点で`~db$に生じている`昇格~tx$を指す。 そのような~txは,あっても一つに限られ、この`~db$を`~access先$とする,ある`接続$に`専属する$。 】
- 【 “昇格~txは `稼働して@ いる( `running^en )” という,未定義の句も現れるが、おそらく,これが ε でないことを意味する。 】
2.1.1. ~db接続
~scriptが`~db$と直に相互作用することはない。 代わりに `接続@ ( `connection^en )を介して間接的に~accessする。 `接続$を利用すれば,`~db$の~objたちを操作できる。 それはまた、その`~db$用の`~tx$を得る唯一の仕方である ◎ Script does not interact with databases directly. Instead, script has indirect access via a connection. A connection object can be used to manipulate the objects of that database. It is also the only way to obtain a transaction for that database.
【 この訳では、 `接続$ %接続 の`~access先$の`~db$を %接続↗ とも記す。 】
`接続$は,`~db$を~openすることにより作成される。 所与の`~db$を`~access先$とする,複数の`接続$が同時にあって~MAY。 ◎ The act of opening a database creates a connection. There may be multiple connections to a given database at any given time.
`接続$が~accessできる`~db$は、その接続を~openした大域~scopeの`生成元$に`専属する$ものに限られる。 ◎ A connection can only access databases associated with the origin of the global scope from which the connection is opened.
注記: これは、 `Document$I の `domain$m が変更されても影響されない。 ◎ This is not affected by changes to the Document's domain.
各 `接続$ %接続 には、次のものが結付けられる(括弧内は、`接続$を表現する `IDBDatabase!I ~interfaceの,対応する~member ): ◎ ↓
- `~version@Cn ( `version$m )
- 作成-時に設定され、それ以降,変わらない。 ただし,`昇格~txが中止-$された場合、 %接続↗ である`~db$は,その元の~versionに戻される。 %接続 が`~close$されて以降は変化しない。 ◎ A connection has a version, which is set when the connection is created. It remains constant for the lifetime of the connection unless an upgrade is aborted, in which case it is set to the previous version of the database. Once the connection is closed the version does not change.
- 【 より詳細には、 %接続↗ の`昇格~tx$dbが`終了-$して以降は変化しない。 】
- `状態@Cn
- %接続 の`状態$Cnは[ `~open中@i → `~close待ち@i → `~close済み@i ]の順に推移する。 後戻りすることはない。 ◎ Each connection has a close pending flag which is initially unset.
- 【 この “状態” は,原文では “close pending flag( ~close待ち~flag )” という(上の `~open中$i と `~close待ち$i を区別する)~flag値で表現されているが、原文の語 “open”, “close pending”, “closed” と状態遷移との対応関係を明瞭にするため,この訳では上のような定義に代えている( “後戻りしない” もこの訳による補完)。 】
-
状態が `~close済み$i になった %接続 は ~closeされた ともいう(そのようにする試みを~closeするという)。 %接続 は、次のときに,`~close$され得る/させれる: ◎ When a connection is initially created it is in opened state. The connection can be closed through several means.\
- %接続 は、それを作成した実行~文脈が破壊された場合には(例えば、利用者が別~頁へ~~移動したことに因り),`~close$される。 ◎ If the execution context where the connection was created is destroyed (for example due to the user navigating away from that page), the connection is closed.\
- `~db接続を~close$する手続きを利用すれば、 %接続 を明示的に`~close$させれる。 ◎ The connection can also be closed explicitly using the steps to close a database connection. When the connection is closed the close pending flag is always set if it hasn’t already been.
- %接続 は、例外的な状況でも~UAにより~closeされてよい/され得る — 例えば、~file~systemへの~accessを失ったとき, ~permission変更, 当の生成元に対する蓄積が消去されたことに因り。 これが生じた場合、~UAは次を入力に `~db接続を~close$し~MUST ⇒# %接続 ~SET %接続, %強制~flag ~SET ~ON ◎ A connection may be closed by a user agent in exceptional circumstances, for example due to loss of access to the file system, a permission change, or clearing of the origin’s storage. If this occurs the user agent must run the steps to close a database connection with the connection and with the forced flag set.
- `保管庫~集合@Cn ( `objectStoreNames$m )
- %接続 の作成-時に, %接続↗ に`専属する$`保管庫$たちの集合に初期化される。 この集合の内容は、 %接続↗ の`昇格~tx$dbが`稼働して$いる間を除いて,一定であり続ける。 ◎ A connection has an object store set, which is initialized to the set of object stores in the associated database when the connection is created. The contents of the set will remain constant except when an upgrade transaction is running.
`接続$の`親~標的を取得する$~algoは、 ~NULL を返す。 ◎ A connection’s get the parent algorithm returns null.
`~version変更~event@ ( `versionchange@et )は、`~db$を昇格する/削除するよう試みたとき,その~dbを~openしている各 `接続$(それを試みている当の`接続$は除く)に向けて発火される。 これは、昇格/削除-を続行できるようにするために,`接続$を~closeする~~機会を与える。 ◎ A version change event will be fired at an open connection if an attempt is made to upgrade or delete the database. This gives the connection the opportunity to close to allow the upgrade or delete to proceed.
2.2. 保管庫
`保管庫@ ( `object store^en )が、`~db$に~dataを格納するための,主たる蓄積の仕組みである。 ◎ An object store is the primary storage mechanism for storing data in a database.
どの`保管庫$も,ある`~db$に`専属する$。 `~db$に専属する`保管庫$の集合は、`昇格~tx$を利用することを通して — すなわち,`upgradeneeded$et ~eventに呼応して — のみ変更できる。 新たな~dbが作成された時点では,それに`専属する$`保管庫$はない。 ◎ Each database has a set of object stores. The set of object stores can be changed, but only using an upgrade transaction, i.e. in response to an upgradeneeded event. When a new database is created it doesn’t contain any object stores.
各 `保管庫$ %保管庫 は、次のものを持つ(括弧内は、保管庫を`~access先$とする `IDBObjectStore!I ~objの対応する~member):
- `~record~list@Os
- %保管庫 内に格納される`~record$の~listを保持する。 ~list内の`~record$どうしは、それらの`~key$の`昇順$に整列される。 同じ保管庫~内で,複数の~recordの`~key$が`等しく$なることは、決してない。 ◎ An object store has a list of records which hold the data stored in the object store. Each record consists of a key and a value. The list is sorted according to key in ascending order. There can never be multiple records in a given object store with the same key.
- `名前@Os ( `name$m )
- `名前$。 この名前は、どの時点においても, %保管庫 が`専属する$`~db$に`専属する$`保管庫$たちにわたって一意になる。 ◎ An object store has a name, which is a name. At any one time, the name is unique within the database to which it belongs.
- `~key~path@Os ( `keyPath$m )
- `妥当な~key~path$, または ε 。 %保管庫 の作成-時に設定され、それ以降( ε かどうかも含め)変わらない。 `~key~path$Osが非 ε であるとき、 “保管庫は~key~pathを持つ” (その否定は “持たない” )とも記される。 ◎ An object store optionally has a key path. If the object store has a key path it is said to use in-line keys. Otherwise it is said to use out-of-line keys.
- 【 原文では、`~key~path$Osが非 ε であることを “use in-line keys” / ε であることを “use out-of-line keys” ]という句で定義しているが、この訳では,これらの句は利用せず,単に “持つ(非 ε )/持たない(ε)” で区別する。 前者を解釈するなら、 “値の中に埋め込まれている( `in-line^en )~keyを利用する” となる所であろう。 】
- 【 保管庫の~key~pathは、空~文字列をとり得ない。 また、`~key生成器$を持つ場合は 文字列の~listもとり得ない。 】
- 【 `~key~path$Os %P を持つ`保管庫$は、その`~record~list$Os内のどの~recordも[ その~key ~EQ~cmpkey `Evaluate$( その値, %P ) ]を満たすように拘束される。 】
- `~key生成器$
- %保管庫 が~key生成器を持つかどうか( `autoIncrement$m )は、 %保管庫 の作成-時に設定され,それ以降 変わらない。 ◎ An object store optionally has a key generator.
`保管庫$は、次のいずれかの~sourceから~recordの`~key$を導出できる。 ◎ An object store can derive a key for a record from one of three sources:
【 すなわち,`~record~list$Osは、外部から与えられる一連の値から,一連の[ ~record{ 導出される~key : 値 } ]で拡充される。 】
- ~keyが必要になる度に,単調に増加する番号による~keyを`~key生成器$から自動的に生成する。 ◎ A key generator. A key generator generates a monotonically increasing numbers every time a key is needed.
- 所与の値から,`~key~path$Os用いて`~keyを抽出-$する。 ◎ Keys can be derived via a key path.
- 保管庫に値を格納するときに,明示的に 【すなわち,格納する~API~methodの引数にて】 ~keyを指定する。 ◎ Keys can also be explicitly specified when a value is stored in the object store.
2.2.1. 保管庫~handle
~scriptが`保管庫$と直に相互作用することはない。 代わりに,ある`~tx$の中で `保管庫~handle@ を介して間接的に~accessする。 ◎ Script does not interact with object stores directly. Instead, within a transaction, script has indirect access via an object store handle.
各 `保管庫~handle$ %H には、次のものが結付けられる(括弧内は、対応する `IDBObjectStore!I ~interface~member): ◎ ↓
- `保管庫@OsH
- %H の`~access先$とされる`保管庫$。 【この訳では、 もっぱら %H↗ と記す。】 ◎ An object store handle has an associated object store\
- `~tx@OsH( `transaction$m )
- %H が`専属する$`~tx$。 【この訳では、この用語は利用せず,単にこのように記す。】 ◎ and an associated transaction.\
- %H の[ 取得時/作成-時 ]に,`可換性$と`一意性$の要件が満たされるように設定される。 ◎ Multiple handles may be associated with the same object store in different transactions, but there must be only one object store handle associated with a particular object store within a transaction.
- `索引~集合@OsH( `indexNames$m )
- %H の作成-時に,[ %H↗ に`専属する$`索引$たちからなる集合 ]に初期化される。 ◎ An object store handle has an index set, which is initialized to the set of indexes that reference the associated object store when the object store handle is created.\
- この集合の内容は、 %H が`専属する$~txが[ `昇格~tx$であって, `稼働して$いる間 ]を除いて,一定であり続ける。 ◎ The contents of the set will remain constant except when an upgrade transaction is running.
- `名前@OsH ( `name$m )
- %H の作成-時に %H↗ の`名前$Osに初期化される。 ◎ An object store handle has a name, which is initialized to the name of the associated object store when the object store handle is created.
- この名前は、 %H が`専属する$~txが[ `昇格~tx$であって, `稼働して$いる ]ときを除いて,一定であり続ける。 ◎ The name will remain constant except when an upgrade transaction is running.
2.X. ~record
[ `保管庫$の`~record~list$Os / `索引$の`~record~list$Ix ]内に格納される各 `~record@ は、以下の節に述べる[ `~key$, および`値$ ]からなる。
所与の ( %~key, %値 ) を ( `~key$, `値$ ) とする`~record$は、 { %~key : %値 } とも表記される。
【 この用語は,原文では保管庫のそれと索引のそれとで区別して定義されているが、それらの総称を表す箇所も多いため,この訳では総称として定義する。 】
2.3. 値
各`~record$には `値@ が結付けられる。 ~UAは、`直列化-可能$などの~objも~supportし~MUST。 これには、少なくとも次のものが含まれる:
- `String$js などの単純~型の~primitive値
- `Date$js
- `Object$js
- `Array$js
- `File$I
- `Blob$I
- `ImageData$I
等々。 ~recordの`値$は、参照~渡しではなく,値~渡しにより[ 格納される/検索取得される ]。 [ 格納-時に渡した/検索取得して得られた ]値が後で変更されても、~db内に格納されている~recordには影響しない。
◎ Each record is associated with a value. User agents must support any serializable object. This includes simple types such as String primitive values and Date objects as well as Object and Array instances, File objects, Blob objects, ImageData objects, and so on. Record values are stored and retrieved by value rather than by reference; later changes to a value have no effect on the record stored in the database.~recordの`値$は、 `StructuredSerializeForStorage$jA 演算から出力される`~Record$である。 ◎ Record values are Records output by the StructuredSerializeForStorage operation.
2.4. ~key
索引付き~db内に格納されている`~record$たちを効率的に検索取得するため、各`~record$は,それぞれの `~key@ に則って組織化される。 ◎ In order to efficiently retrieve records stored in an indexed database, each record is organized according to its key.
各 `~key$は次のものを持つ:
- `種別@key
- 次のいずれか: `number@i / `date@i / `string@i / `binary@i / `array@i ◎ A key has an associated type which is one of: number, date, string, binary, or array.
- `値@key
-
~keyの`種別$keyに応じて,次の型の値をとる:
- `number$i
- `date$i
- WebIDL `unrestricted double$I 型
- `string$i
- WebIDL ~DS型
- `binary$i
- WebIDL `octet$I 型~値の~list
- `array$i
- (種別 `array$i のものも含め,)他の`~key$からなる~list
ECMAScript `ECMA-262$r 値は、`~keyへ変換-$する手続きに従って`~key$に変換される。 ◎ An ECMAScript [ECMA-262] value can be converted to a key by following the steps to convert a value to a key.
次のいずれかの ECMAScript 型が,~keyとして妥当になる: ◎ The following ECMAScript types are valid keys:
- `NaN^js 以外の `Number$js ~primitive値。 `Infinity^js, `-Infinity^js も含まれる。 ◎ Number primitive values, except NaN. This includes Infinity and -Infinity.
- `Date$js ~objであって,その `DateValue^sl 内部~slotは `NaN^js でないもの。 ◎ Date objects, except where the [[DateValue]] internal slot is NaN.
- `String$js ~primitive値。 ◎ String primitive values.
- 各種 `~buffer~source型$ 値。 ( `ArrayBuffer$js ~objや, `Uint8Array$js などの~buffer~view)。 ◎ ArrayBuffer objects (or views on buffers such as Uint8Array).
- `Array$js ~objであって、[ 配列~内の どの~itemも定義されていて,~keyとして妥当である ], かつ[ (直接的にも間接的にも)自身を包含していない ]もの。 特に,空の配列は妥当である。 配列は,他の配列を包含し得る。 ◎ Array objects, where every item is defined, is itself a valid key, and does not directly or indirectly contain itself. This includes empty arrays. Arrays can contain other arrays.
他の ECMAScript 値を`~key$に変換しようと試みても失敗することになる。 ◎ Attempting to convert other ECMAScript values to a key will fail.
`種別$key `array$i の`~key$を特に `配列~key@ という。 `配列~key$の`値$key ~listの各~memberを `下位key@ という。 ◎ An array key is a key with type array. The subkeys of an array key are the members of the array key's value list.
2 つの`~key$ %a, %b を `比較-@key する関数 `Compare$( %a, %b ) は、次で定義される: ◎ To compare two keys a and b, run these steps:
-
`~key$の各 `種別$key 間の大小関係を[ `number$i ~LT `date$i ~LT `string$i ~LT `binary$i ~LT `array$i ]と定義する下で:
- ~IF [ %a の`種別$key ~GT %b の`種別$key ] ⇒ ~RET 1
- ~IF [ %a の`種別$key ~LT %b の`種別$key ] ⇒ ~RET −1
- %va ~LET %a の`値$key ◎ Let va be the value of a.
- %vb ~LET %b の`値$key ◎ Let vb be the value of b.
-
%a の`種別$keyに応じて: ◎ Switch on ta:
- `number$i
- `date$i
-
- ~IF[ %va ~GT %vb ] ⇒ ~RET 1 ◎ If va is greater than vb, then return 1.
- ~IF[ %va ~LT %vb ] ⇒ ~RET −1 ◎ If va is less than vb, then return -1.
- ~RET 0 ◎ Return 0.
- `string$i
-
-
~EACH( 整数 %i ~IN { 0 〜 min( %va の長さ, %vb の長さ ) ~MINUS 1 } ) に対し,昇順に: ◎ Let length be the lesser of va’s length and vb’s length. ◎ Let i be 0. ◎ While i is less than length, then:
- %u ~LET %va の~index %i の符号単位 ◎ Let u be the code unit of va at index i.
- %v ~LET %vb の~index %i の符号単位 ◎ Let v be the code unit of vb at index i.
- ~IF[ %u ~GT %v ] ⇒ ~RET 1 ◎ If u is greater than v then return 1.
- ~IF[ %u ~LT %v ] ⇒ ~RET −1 ◎ If u is less than v then return -1. ◎ Increase i by 1.
- ~IF[ %va の長さ ~GT %vb の長さ ] ⇒ ~RET 1 ◎ If va’s length is greater than vb’s length, then return 1.
- ~IF[ %va の長さ ~LT %vb の長さ ] ⇒ ~RET −1 ◎ If va’s length is less than vb’s length, then return -1.
- ~RET 0 ◎ Return 0.
-
- `binary$i
-
-
~EACH( 整数 %i ~IN { 0 〜 min( %va の長さ, %vb の長さ ) ~MINUS 1 } ) に対し,昇順に: ◎ Let length be the lesser of va’s length and vb’s length. ◎ Let i be 0. ◎ While i is less than length, then:
- %u ~LET %va の~index %i の `octet$I ◎ Let u be the octet in va at index i.
- %v ~LET %vb の~index %i の `octet$I ◎ Let v be the octet in vb at index i.
- ~IF[ %u ~GT %v ] ⇒ ~RET 1 ◎ If u is greater than v then return 1.
- ~IF[ %u ~LT %v ] ⇒ ~RET −1 ◎ If u is less than v then return -1. ◎ Increase i by 1.
- ~IF[ %va の長さ ~GT %vb の長さ ] ⇒ ~RET 1 ◎ If va’s length is greater than vb’s length, then return 1.
- ~IF[ %va の長さ ~LT %vb の長さ ] ⇒ ~RET −1 ◎ If va’s length is less than vb’s length, then return -1.
- ~RET 0 ◎ Return 0.
-
- `array$i
-
-
~EACH( 整数 %i ~IN { 0 〜 min( %va の長さ, %vb の長さ ) ~MINUS 1 } ) に対し,昇順に ◎ Let length be the lesser of va’s length and vb’s length. ◎ Let i be 0. ◎ While i is less than length, then:
- %u ~LET %va 内の~index %i の`~key$ ◎ Let u be the key in va at index i.
- %v ~LET %vb 内の~index %i の`~key$ ◎ Let v be the key in vb at index i.
- %c ~LET `Compare$( %u, %v ) ◎ Let c be the result of recursively running the steps to compare two keys with u and v.
- ~IF[ %c ~NEQ 0 ] ⇒ ~RET %c ◎ If c is not 0, return c. ◎ Increase i by 1.
- ~IF[ %va の長さ ~GT %vb の長さ ] ⇒ ~RET 1 ◎ If va’s length is greater than vb’s length, then return 1.
- ~IF[ %va の長さ ~LT %vb の長さ ] ⇒ ~RET −1 ◎ If va’s length is less than vb’s length, then return -1.
- ~RET 0 ◎ Return 0.
-
2 つの`~key$ %a, %b の大小関係は、 `Compare$( %a, %b ) の結果に応じて:
- 1 の場合
- %a は %b `より大きい@ とされる。 ◎ The key a is greater than the key b if the result of running the steps to compare two keys with a and b is 1.
- −1 の場合
- %a は %b `より小さい@ とされる。 ◎ The key a is less than the key b if the result of running the steps to compare two keys with a and b is -1.
- 0 の場合
- %a は %b に `等しい@ とされる。 ◎ The key a is equal to the key b if the result of running the steps to compare two keys with a and b is 0.
注記: 上の規則の結果として,負の `Infinity^js が, `~key$がとり得る最小の値になる。 最大の`~key$値は存在しない — いかなる`配列~key$に対しても、その末尾に新たな`~key$を付加した結果の配列は,より大きくなるので。 ◎ As a result of the above rules, negative infinity is the lowest possible value for a key. Number keys are less than date keys. Date keys are less than string keys. String keys are less than binary keys. Binary keys are less than array keys. There is no highest possible key value. This is because an array of any candidate highest key followed by another key is even higher.
注記: 種別 `binary$i の`~key$を成す各 `octet$I 値は、符号なし(範囲 [0, 255] )として比較される — `byte$I 値ではなく。 ◎ Members of binary keys are compared as unsigned octet values (in the range [0, 255]) rather than signed byte values (in the range [-128, 127]).
この訳では、表記 “%記号key” を用いて、次を表すことにする:
- 2 つの`~key$ %a, %b の`比較-$key
- 2 つの`~key$~pair %p ~EQ ( %a1, %a2 ), %q ~EQ ( %b1, %b2 ) の比較†
- `~key$ %k が`~key範囲$ %R に`入る$かどうか
- `~key$ %k が`~key$の集合 %K に含まれるかどうか
表記 | 定義 |
---|---|
%a ~GT~cmpkey %b | %a は %b `より大きい$ |
%a ~LT~cmpkey %b | %a は %b `より小さい$ |
%a ~EQ~cmpkey %b | %a は %b に`等しい$ |
%a ~GTE~cmpkey %b | [ %a ~GT~cmpkey %b ]~OR[ %a ~EQ~cmpkey %b ] |
%a ~LTE~cmpkey %b | [ %a ~LT~cmpkey %b ]~OR[ %a ~EQ~cmpkey %b ] |
%p ~GT~cmpkey %q | [ %a1 ~GT~cmpkey %b1 ]~OR[[ %a1 ~EQ~cmpkey %b1 ]~AND[ %a2 ~GT~cmpkey %b2 ]] |
%p ~LT~cmpkey %q | [ %a1 ~LT~cmpkey %b1 ]~OR[[ %a1 ~EQ~cmpkey %b1 ]~AND[ %a2 ~LT~cmpkey %b2 ]] |
%p ~EQ~cmpkey %q | [ %a1 ~EQ~cmpkey %b1 ]~AND[ %a2 ~EQ~cmpkey %b2 ] |
%p ~GTE~cmpkey %q | [ %p ~GT~cmpkey %q ]~OR[ %p ~EQ~cmpkey %q ] |
%p ~LTE~cmpkey %q | [ %p ~LT~cmpkey %q ]~OR[ %p ~EQ~cmpkey %q ] |
%k ~IN~cmpkey %R | %k は %R に`入る$ |
%k ~NIN~cmpkey %R | %k ~IN~cmpkey %R の否定 |
%k ~IN~cmpkey %K | ある %key ~IN %K に対し, %k ~EQ~cmpkey %key |
%k ~NIN~cmpkey %K | %k ~IN~cmpkey %K の否定 |
† `~key$~pairの比較は、簡潔に記すための,この訳による追加の定義であり、もっぱら,`索引$の~record(または,[ それを意図して, あるいは それとの比較を意図して ]与えられる~key値~pair)を比較するときに用いられる。
2.5. ~key~path
`~key~path@ は文字列,または文字列の~listであり、`値$から`~key$を抽出する方法を定義する。 次に挙げるものが `妥当な~key~path@ とされる: ◎ A key path is a string or list of strings that defines how to extract a key from a value. A valid key path is one of:
- 空~文字列 ◎ An empty string.
- `識別子@ — すなわち, `ECMA-262$r の `IdentifierName$js 生成規則に合致する文字列 ◎ An identifier, which is a string matching the IdentifierName production from the ECMAScript Language Specification [ECMA-262].
- 複数の`識別子$を~PERIODで~~区切って~~連結して得られる,文字列 ◎ A string consisting of two or more identifiers separated by periods (U+002E FULL STOP).
- 上の要件に適合する文字列のみを包含するような,空でない~list ◎ A non-empty list containing only strings conforming to the above requirements.
注記: ~key~pathの中では space は許容されない。 ◎ Spaces are not allowed within a key path.
`~key~path$で~accessできる部位は、 `StructuredSerializeForStorage$jA により明示的に複製される~propに限られる — 次に挙げる各種~型に特有の~propも含まれる: ◎ Key path values can only be accessed from properties explicitly copied by StructuredSerializeForStorage, as well as the following type-specific properties:
型◎ Type | ~prop◎ Properties |
---|---|
`Blob$I | `size^m, `type^m |
`File$I | `name^m, `lastModified^m, `lastModifiedDate^m |
`Array$js | `length^js |
`String$js | `length^js |
【 `File^I に対しては、 `Blob^I を継承するので,上に挙げた `Blob^I の~propも含まれることになる。 】
【補記:】
`~key~path$は、任意に与えられる値( ~obj )の中のある一定の部位を表現する。 その目的は、外部から与える一連の値で,`保管庫$を 拡充する とき — すなわち,値を`保管庫$の`~record~list$Osの中に`~record$の`値$として格納するとき — に、それらの値の中の[ ~key~pathが指す部位に与えられている~data ]から,自動的に`~key$を導出することである。 あるいは、`索引$を,それが`専属する$`保管庫$の`~record~list$Osに基づいて拡充するときにも、同様に利用される。 例えば:
2.6. 索引
`~key$以外の手段を通して,`保管庫$内の`~record$たちを検索取得できると有用になることもときどきある。 `索引@ ( `index^en )により、`保管庫$内の`~record$たちを,それらの`値$の~propを通して検索できるようになる。 ◎ It is sometimes useful to retrieve records in an object store through other means than their key. An index allows looking up records in an object store using properties of the values in the object stores records.
索引は、ある~~目的に特化された`~record$たちからなる永続的な蓄積であり、その~dataは,以下に述べるように 索引が`専属する$`保管庫$の~dataに基いて拡充される。 各 索引は、次のものを持つ(括弧内は、索引を`~access先$とする `IDBIndex!I ~objの対応する~member ): ◎ An index is a specialized persistent key-value storage and has a referenced object store. The index has a list of records which hold the data stored in the index. The records in an index are automatically populated whenever records in the referenced object store are inserted, updated or deleted. There can be several indexes referencing the same object store, in which changes to the object store cause all such indexes to get updated.
- `参照先の保管庫@
- 索引が`専属する$`保管庫$。 【この訳では、この用語は利用せず,単にこのように記す。】 索引の作成-時に設定される。 以下の各項では、単に %保管庫 と記す。 ◎ ↑
- `~record~list@Ix
-
索引に格納される~dataを保持する,一連の`~record$からなる~list。 この~listは、 %保管庫 の`~record~list$Os %L から自動的に拡充される:
- 索引の作成-時に, %L に基づいて自動的に拡充される。
- %L [ に~recordが挿入される / から~recordが削除される / の~recordの`値$が更新される ]度に,自動的に拡充される。
%L に変更が加えられる度に, %保管庫 に`専属する$すべての索引は更新されることになる。
【 どのような原則に基づいて拡充されるかの詳細は、索引の拡充-法節に述べる。 】
◎ ↑↓ - `~key~path@Ix ( `keyPath$m )
-
`~key~path$。
索引~内のどの~record %R1 についても:
-
%R1 の`値$は %保管庫 内のある~record %R の`~key$で与えられる。
【 したがって、`保管庫$における`~key$の一意性から,索引の`~record~list$Ix から %保管庫 の`~record~list$Os %L への対応関係:
%R1 → %R ~EQ [ %R1 の`値$を`~key$とする %L 内の~record ]
が定義できる。 この訳では、この %R を %R1 の `参照先~record@ と呼ぶことにする。 】
- %R1 の`~key$は[ %R の`値$の中の,この`~key~path$Ixが指す部位 ]から`抽出される~key$(たちのいずれか)で与えられる。
索引の`~record~list$Ixは,そのように %R から導出される %R1 たちで拡充される。
◎ The values in the index’s records are always values of keys in the index’s referenced object store. The keys are derived from the referenced object store’s values using a key path. If a given record with key X in the object store referenced by the index has the value A, and evaluating the index’s key path on A yields the result Y, then the index will contain a record with key Y and value X. -
-
上述の %R (すなわち, %R1 の`参照先~record$)の`値$は、 %R1 の `参照先の値@ と呼ばれる。 【この訳では、この用語は利用せず,単に`参照先~record$の値と称することにする。】 ◎ Records in an index are said to have a referenced value. This is the value of the record in the index’s referenced object store which has a key equal to the index’s record’s value. So in the example above, the record in the index whose key is Y and value is X has a referenced value of A.
注記: 【この段落の内容は、索引の拡充-法節に委譲。】 ◎ Each record in an index references one and only one record in the index’s referenced object store. However there can be multiple records in an index which reference the same record in the object store. And there can also be no records in an index which reference a given record in an object store.
索引~内の`~record$たちは、常にその~keyに則って整列される。 保管庫と違い、索引は,同じ~keyを伴う複数の~recordを包含し得るので、それらの~recordは更に,それらの`値$(すなわち,`参照先~record$の~key)に則って整列される。 ◎ The records in an index are always sorted according to the record’s key. However unlike object stores, a given index can contain multiple records with the same key. Such records are additionally sorted according to the index’s record’s value (meaning the key of the record in the referenced object store).
- `名前@Ix ( `name$m )
- `名前$。 この名前は、どの時点においても,同じ`保管庫$に`専属する$索引たちにわたって一意になる。 ◎ An index has a name, which is a name. At any one time, the name is unique within index’s referenced object store.
- `一意~flag@Ix ( `unique$m )
- ~ON に設定された下では、索引の~record~listは[ 索引~内のどの 2 つの`~record$も同じ~keyを持たない ]条件の下で拡充される。 索引が`専属する$`保管庫$にて[ `~record$を 挿入する/改変する ]ような試みは、[ 索引の`~key~path$Ixを用いて その~recordの値から`抽出される~key$(たちのいずれか) ]が[ 索引~内のある~recordの~key ]と同じになる(`等しい$)ならば,失敗する。 ◎ An index has a unique flag. When this flag is set, the index enforces that no two records in the index has the same key. If a record in the index’s referenced object store is attempted to be inserted or modified such that evaluating the index’s key path on the records new value yields a result which already exists in the index, then the attempted modification to the object store fails.
- 【 新たな索引を作成する試みも,条件を満たせないときは同様に失敗する。 この場合の取り扱いは `IDBObjectStore.createIndex()$m にて述べられる。 】
- `複entry~flag@Ix ( `multiEntry$m )
-
この~flagは、索引の`~key~path$Ixが指す( %保管庫 に追加された`~record$の)部位が配列であるとき,索引がどう挙動するかに影響する: ◎ An index has a multiEntry flag. This flag affects how the index behaves when the result of evaluating the index’s key path yields an array key.\
- ~OFF の場合 ⇒ 索引には,その配列をそのまま`配列~key$とするような,単独の`~record$が追加される。 ◎ If the multiEntry flag is unset, then a single record whose key is an array key is added to the index.\
- ~ON の場合 ⇒ 索引には,その配列~内の重複を除いた各`~key$ %key ごとに,[ %key を`~key$にするような,`~record$ ]が追加される。 この場合、 `~key~path$Ixは文字列の~listをとり得ない。 ◎ If the multiEntry flag is true, then the one record is added to the index for each of the subkeys.
- 【 この機能により、各~recordに複数の “タグ” が付与されているような`~record~list$Osに対し,タグで検索するための索引を作成したり、ある部位においてのみ異なる多数の`~record$を,一つに集約した上で取扱うことが可能になる。 】
【索引の拡充-法】
【 この節は、原文の記述から導出した,この訳による補完である。 】
`索引$ %索引 の`~record~list$Ix %L1 が精確にどのように, %索引 が`専属する$`保管庫$の`~record~list$Os %L から拡充されるかの詳細を、以下に定式化する(具体的な~algoは、 各種~db演算 節にて定義される)。
まず、 %L 内の`~record$ %R に対し, `抽出される~key@ の集合 K( %R ) は,次で定義される:
K( %R ) ~EQ `ExtractKeySet$( %R の`値$ , %索引 の`~key~path$Ix , %索引 の`複entry~flag$Ix )
%L1 は,常に次の拘束が満たされるように拡充される:
-
%L 内のどの %R に対しても、各`~key$ %key ~IN K( %R ) に対し,次の両~条件を満たす~record %R1 が %L1 内に唯一つ存在する:
- %R1 の`~key$ ~EQ~cmpkey %key
- %R1 の`値$ ~EQ~cmpkey %R の`~key$
- %L1 は、前項により導出されるもの以外の`~record$は含まない。
%R が %R1 の`参照先~record$を与える。 [ %索引 の`複entry~flag$Ix ~EQ ~OFF ]ならば、集合 K( %R ) は,常に 0 〜 1 個の~keyからなるので、 %L1 から %L への対応関係[ %R1 → %R1 の`参照先~record$ ]は 単射になる。 また、 K( %R ) が常に空でないならば、この対応関係は全射になる。
したがって、索引の`~record~list$Ixは,索引が専属する保管庫の`~record~list$Osから一意に定まることになる。 例えば、保管庫に~recordを追加してから新たな索引を作成した結果と,これを逆順で行った結果は(~errorが生じなければ)同じになる。 よって、索引の~record~listを実際に構築しない実装も,原理的に可能になる(処理能 — 例えば~recordの整列-など — との引き換えになるが)。 (また,そのように~model化すれば、この仕様の記述は より簡略化できるであろう。)
2.6.1. 索引~handle
~scriptが`索引$と直に相互作用することはない。 代わりに`~tx$の中で `索引~handle@ を介して間接的に~accessする。 ◎ Script does not interact with indexes directly. Instead, within a transaction, script has indirect access via an index handle.
各`索引~handle$ %I には、次のものが結付けられる(括弧内は、対応する `IDBIndex!I ~interface~member ): ◎ ↓
- `索引@IxH
- %I の`~access先$とされる`索引$。 【この訳では、 もっぱら %I↗ と記す。】 ◎ An index handle has an associated index\
- `保管庫~handle@IxH( `objectStore$m )
- %I が`専属する$`保管庫~handle$。 【この訳では、この用語は利用せず,単にこのように記す。】 ◎ and an associated object store handle.\
- `~tx@IxH
- %I (が`専属する$`保管庫~handle$)が`専属する$`~tx$。 【この訳では、この用語は利用せず,単にこのように記す。】 ◎ The transaction of an index handle is the transaction of its associated object store handle.
- 上に挙げた %I の[ 索引, 保管庫~handle, ~tx ]は、 %I の[ 取得時/作成-時 ]に,`可換性$と`一意性$の要件が満たされるように設定される。 ◎ Multiple handles may be associated with the same index in different transactions, but there must be only one index handle associated with a particular index within a transaction.
- `名前@IxH ( `name$m )
- %I の作成-時に %I↗ の`名前$Ixに初期化される。 この名前は、 %I が`専属する$`~tx$が[ `昇格~tx$であって, `稼働して$いる ]ときを除いて,一定であり続ける。 ◎ An index handle has a name, which is initialized to the name of the associated index when the index handle is created. The name will remain constant except when an upgrade transaction is running.
2.7. ~tx
`~db$内の~dataと相互作用するとき — すなわち,~dataを読取する/書込するとき — は、常に `~tx@ ( `transaction^en )が利用される。 ◎ A Transaction is used to interact with the data in a database. Whenever data is read or written to the database it is done by using a transaction.
`~tx$は、[ ~app/~system ]の失敗に対する一定の保護を提供する:
- 一度に複数の~data~recordを格納したり,~data~recordを条件付きで改変するために利用できる。
- 時間を要する[ ~data~access/~data変異 ]演算からなる,不可分的な集合を表現する。
【 すなわち,失敗-時には、中途半端な状態にならないように,これらによる変異すべてが元の状態に復帰される。 】
◎ Transactions offer some protection from application and system failures. A transaction may be used to store multiple data records or to conditionally modify certain data records. A transaction represents an atomic and durable set of data access and data mutation operations.各 `~tx$は、次のものを持つ(括弧内は、対応する `IDBTransaction!I ~interface~member ):
- `接続@tx ( `db$m )
- すべての`~tx$は、ある`接続$を通して`作成-$される(後述の`存続期間$を見よ)。 ~txは、その`接続$に`専属する$。 ◎ All transactions are created through a connection, which is the transaction’s connection.
- 【 この訳では、この接続を指すときは,もっぱら “(~txが)専属する接続” と記す。 】
- `視野@ ( `objectStoreNames$m )
- `~tx$が相互作用し得る`保管庫$たちからなる集合。 視野は、~txの作成-時に決定され,~txが存続する限り固定され続ける†。 ◎ A transaction has a scope that determines the object stores with which the transaction may interact. A transaction’s scope remains fixed for the lifetime of that transaction.
- 【† `昇格~tx$については、その視野は 常に, それが`専属する$`接続$の`保管庫~集合$Cnになる。 】
- 【 それぞれの~txは、同じ`保管庫$を, 別々の`保管庫~handle$を通して 各自の “視野に入れる” ことに注意。 】
- `~mode@ ( `mode$m )
-
`~tx$が,どの型の相互作用を遂行できるかを決定する。 `~mode$は,~txの作成-時に設定され、~txが存続する間 変わらない。 次のいずれか: ◎ A transaction has a mode that determines which types of interactions can be performed upon that transaction. The mode is set when the transaction is created and remains fixed for the life of the transaction. A transaction’s mode is one of the following:
- `readonly@l
- この型の`~tx$には、~dataを読取することのみが許容され,改変は行えない。 `readonly^l ~txには、複数のそれらを同時に稼働できる優位性がある — 互いの`視野$が重なっていようが(すなわち,同じ保管庫を利用していても)。 この型の~txは、~dbが~openされたなら,いつでも作成できる。 ◎ The transaction is only allowed to read data. No modifications can be done by this type of transaction. This has the advantage that several read-only transactions can run at the same time even if their scopes are overlapping, i.e. if they are using the same object stores. This type of transaction can be created any time once a database has been opened.
- `readwrite@l
- この型の`~tx$には、既存の保管庫から~dataを読取することに加えて,~dataを[ 改変する/削除する ]ことも許容される。 しかしながら、保管庫や索引を[ 追加する, 除去する ]ことはできない。 また、[ 互いの`視野$が重なるような複数の `readwrite^l `~tx$ ]を同時に稼働させることはできない — そうすると,~txの間に互いの~dataを改変し得ることになるので。 この型の~txは、~dbが~openされたなら,いつでも作成できる。 ◎ The transaction is allowed to read, modify and delete data from existing object stores. However object stores and indexes can’t be added or removed. Multiple "readwrite" transactions can’t run at the same time if their scopes are overlapping since that would mean that they can modify each other’s data in the middle of the transaction. This type of transaction can be created any time once a database has been opened.
- 【 手短に言えば、視野に入れている保管庫たちを排他的に占有する。 】
- `versionchange@l
- この型の`~tx$には、既存の保管庫から~dataを[ 読取する, 改変する, 削除する ]ことに加えて,保管庫や索引を[ 作成する, 除去する ]こともできる。 それは、この型の~txのみが行い得る。 この型の~txは、手動では作成できない — 代わりに `upgradeneeded$et ~eventが発火されるときに自動的に作成される。 ◎ The transaction is allowed to read, modify and delete data from existing object stores, and can also create and remove object stores and indexes. It is the only type of transaction that can do so. This type of transaction can’t be manually created, but instead is created automatically when an upgradeneeded event is fired.
- 【 手短に言えば、接続先~db全体を排他的に占有する。 `昇格~tx$とも呼ばれる。 】
- `作動中~flag@
- この~flagが ~ON のとき, そのときに限り,~txは `作動中@ であるとされ、`要請$を~txに`設置-$できる。 ◎ A transaction has an active flag, which determines if new requests can be made against the transaction. A transaction is said to be active if its active flag is set.
- `片付ける~event-loop@
- `~event-loop$, または ε (初期-時) ◎ A transaction optionally has a cleanup event loop which is an event loop.
- `要請~list@
- ~txに`設置-$された`要請$たちからなる, 【設置された順による】~list。 ◎ A transaction has a request list of requests which have been made against the transaction.
- `~error@tx
- 初期時は ε 。 `~tx$が~errorにより`中止-$されたときに設定される。 ◎ A transaction has a error which is set if the transaction is aborted.
`~tx$の`親~標的を取得する$~algoは、~txが`専属する$`接続$を返す。 ◎ A transaction’s get the parent algorithm returns the transaction’s connection.
`~mode$が `readonly$l にされた`~tx$を `~readonly~tx@ という。 ◎ A read-only transaction is a transaction with mode "readonly".
`~mode$が `readwrite$l にされた`~tx$を `~readwrite~tx@ という。 ◎ A read/write transaction is a transaction with mode "readwrite".
2.7.1. ~txの存続期間
`~tx$は短命であるものと期待されている。 これは、下に述べる自動`~commit$の機能性により促される。 ◎ Transactions are expected to be short lived. This is encouraged by the automatic committing functionality described below.
注記: 作者は依然として,~txを長い間 稼働させれるが、そのような用法は 利用者~体験を~~悪化させ得るので,勧められない。 ◎ Authors can still cause transactions to run for a long time; however, this usage pattern is not advised as it can lead to a poor user experience.
`~tx$はその `存続期間@ にわたり、以下のように変遷する: ◎ The lifetime of a transaction is as follows:
-
作成する: `~tx$は、`~mode$と`視野$を伴って `作成-@ される。 同時に†、~txの`作動中~flag$は ~ON にされる。
【† 実際には、 `success$et/`error$et ~event(`昇格~tx$に対しては `upgradeneeded$et ~event)が配送されている間に限り ~ON にされている。 】
◎ A transaction is created with a scope and a mode. When a transaction is created its active flag is initially set. -
要請を設置する: 実装は:
- `作動中$にある`~tx$に対しては,`要請$を`設置-$できるようにし~MUST。
- `作動中$でない`~tx$に対し,要請を`設置-$しようと試みられた場合、`TransactionInactiveError$E を投出して,却下し~MUST。
- まだ`開始-$されてない`~tx$に対し`設置-$された`要請$たちは、`開始-$されるまで,実行しては~MUST_NOT — 代わりに、それらの要請を,その順序も込みで保ち続け~MUST。
- 開始する: 実装は、以下に定義される[ `~tx$の`~mode$と`視野$に定義される拘束 ]を施行できるようになったなら,~txを非同期に `開始-@ する`~taskを~queueし$~MUST。 ◎ Once an implementation is able to enforce the constraints defined for the transaction scope and mode, defined below, the implementation must queue a task to start the transaction asynchronously.
- 要請を実行する: `~tx$が`開始-$されたなら、その~txに設置された各`要請$を `実行-@ できるようになる。 他から定義されない限り、それらの要請は,`設置-$された順序で実行され~MUST。 同様に,それらの結果も、同じ順序で返され~MUST 【返すとは、要請に向けてその完了を報告する~eventを発火することを意味する】 — 異なる~txに`設置-$された要請たちの間では,返される順序は保証されないが。 同様に,~txの`~mode$により、[ 互いに異なる~txに対し, 2 つの要請の どちらが先に設置された ]としても,[ ~db内に格納される結果の~dataには影響しない ]ことが確保される。 ◎ Once the transaction has been started the implementation can start executing the requests placed against the transaction. Unless otherwise defined, requests must be executed in the order in which they were made against the transaction. Likewise, their results must be returned in the order the requests were placed against a specific transaction. There is no guarantee about the order that results from requests in different transactions are returned. Similarly, the transaction modes ensure that two requests placed against different transactions can execute in any order without affecting what resulting data is stored in the database.
- 中止する: `~tx$は、`終了-$する前に,いつでも `中止-@ され得る/できる — ~txが`作動中$であろうと,まだ`開始-$されていなくても。 ~txが中止されるときは、実装は,その~txの間に `~db$に発行0されたすべての変更を,元に復帰させ~MUST 【“巻戻し( `roll back^en )” とも称される】。 これには、[ `保管庫$の内容に対する変更 / `保管庫$や`索引$の[ 追加/除去 ]]も含まれる。 ◎ A transaction can be aborted at any time before it is finished, even if the transaction isn’t currently active or hasn’t yet started. When a transaction is aborted the implementation must undo (roll back) any changes that were made to the database during that transaction. This includes both changes to the contents of object stores as well as additions and removals of object stores and indexes.
-
失敗: `~tx$は、特定0の`要請$に結付けられない事由でも失敗し得る。 例えば、~txを`~commit$する際の IO ~errorや, 特定0の要請には結付けられないような~quota上限を超過することに因り。 この事例では、実装は,次を入力に`~txを中止-$し~MUST ⇒# %~tx ~SET ~tx, %error ~SET 適切な~error名†
† 例えば ~quotaを超過した場合は `QuotaExceededError$E / IO ~errorの場合は `UnknownError$E を利用すべきである。
◎ A transaction can fail for reasons not tied to a particular request. For example due to IO errors when committing the transaction, or due to running into a quota limit where the implementation can’t tie exceeding the quota to a partcular request. In this case the implementation must run the steps to abort a transaction using the transaction as transaction and the appropriate error type as error. For example if quota was exceeded then a "QuotaExceededError" DOMException should be used as error, and if an IO error happened, an "UnknownError" DOMException should be used as error. -
~commitする: 実装は、すでに開始された`~tx$がこれ以上 `作動中$になり得ないとき†は、`中止-$されていない限り,それを `~commit@ しようと~~試み~MUST。 これは通例的に,[ ~txに設置されたすべての要請が実行され,それらが返した結果が取扱われた後に,かつ ~txに対し新たな要請は設置されていないとき† ]に起こる。 ◎ When a transaction has been started and it can no longer become active, the implementation must attempt to commit it, as long as the transaction has not been aborted. This usually happens after all requests placed against the transaction have been executed and their returned results handled, and no new requests have been placed against the transaction.\
【† 具体的には、結果を取扱う~event~handlerの中で,新たな要請が設置されなかったなら、~commitされる,と考えられる。 】
`~tx$を~commitするときは、実装は,~txに対し設置された要請により発行0されたすべての変更を,`~db$に不可分的に書込しなければならばい。 すなわち、[ 変更のすべてが書込される ]か,または[ ~disk書込などの~errorが生じた場合には、いかなる変更も~dbに書込されない ]かの,いずれかで~MUST。 ◎ When a transaction is committed, the implementation must atomically write any changes to the database made by requests placed against the transaction. That is, either all of the changes must be written, or if an error occurs, such as a disk write error, the implementation must not write any of the changes to the database.\
~errorが生じた場合、実装は`~txを中止-$する手続きに従って,~txを`中止-$し~MUST。 他の場合、`~txを~commit$する手続きに従って~txを`~commit$し~MUST。 ◎ If such an error occurs, the implementation must abort the transaction by following the steps to abort a transaction, otherwise it must commit the transaction by following the steps to commit a transaction.
-
終了-: `~tx$は、それが[ `~commit$された, または `中止-$された† ]時点で, `終了-@ したとされる。 `~tx$を終了できない場合 — 例えば、実装が~crashした, あるいは 利用者が~txを取消すような何らかの明示的な動作をとったことに因り — 実装は、~txを`中止-$し~MUST††。 ◎ When a transaction is committed or aborted, it is said to be finished. If a transaction can’t be finished, for example due to the implementation crashing or the user taking some explicit action to cancel it, the implementation must abort the transaction.
【 中止-が要請された時点なのか,それにより`~txを中止-$する手続きを終えた時点なのか、はっきりしない。 】【†† ~crashした(あるいは利用者がブラウザを強制終了させたとき)実装は何もできなくなるので,この記述はおかしいが、~commitされないまま内部状態も消し飛ぶので,中止された(復帰された)のと同じことになると考えられる。 】
`~tx$の開始~時機は、以下に挙げる拘束により定義される: ◎ The following constraints define when a transaction can be started:
`~readonly~tx$は、同時並行的にいくつでも — 互いの`視野$が重なっていようが — 稼働することが許容される。 `~readonly~tx$に対しては、稼働している限り,実装が, その~txにより作成された`要請$を通して返す~dataは、一定であり続け~MUST。 すなわち,同じ~data片を読取する 2 つの要請は、~dataが見出されるかどうかも含め,同じ結果を得~MUST。 ◎ Any number of read-only transactions are allowed to run concurrently, even if the transaction’s scope overlap and include the same object stores. As long as a read-only transaction is running, the data that the implementation returns through requests created with that transaction must remain constant. That is, two requests to read the same piece of data must yield the same result both for the case when data is found and the result is that data, and for the case when data is not found and a lack of data is indicated.
実装がこれを確保する仕方はいくつもある。 例えば,`~readwrite~tx$に対し、視野が重なる`~readonly~tx$が他にあるときは,それらが`終了-$するまで`開始-$を遅らすこともできる。 あるいは,`~readonly~tx$に対しては、その開始-時点での`保管庫$の~snapshotを常に見るようにする方法もある。 ◎ There are a number of ways that an implementation can ensure this. The implementation could prevent any read/write transaction, whose scope overlaps the scope of the read-only transaction, from starting until the read-only transaction finishes. Or the implementation could allow the read-only transaction to see a snapshot of the contents of the object stores which is taken when the read-only transaction started.
同様に、実装は 次を確保し~MUST: ◎ Similarly, implementations must\
- `~readwrite~tx$は,それを利用して発行0された`保管庫$への変更~以外からは影響されないこと — 例えば、別の~txが,`~readwrite~tx$の`視野$に入る`保管庫$の内容を改変しないこと。 ◎ ensure that a read/write transaction is only affected by changes to object stores that are made using the transaction itself. For example, the implementation must ensure that another transaction does not modify the contents of object stores in the read/write transaction’s scope.\
- 成功裡に完了した`~readwrite~tx$により`保管庫$に書込された変更は,`~tx$間で互いに競合することなく — 競合に因り~txを中止することなく — `~db$に~commitできること。 ◎ The implementation must also ensure that if the read/write transaction completes successfully, the changes written to object stores using the transaction can be committed to the database without merge conflicts. An implementation must not abort a transaction due to merge conflicts.
- 複数の`~readwrite~tx$が同じ保管庫に~accessしようと試みた(すなわち,それらの`視野$が重なっている)場合、先に`作成-$された~txが保管庫への~accessを先に取得すること。 前 2 項による要件に因り、これは[ その~txが`終了-$するまで,保管庫に~accessできるのはその~txに限られる ]ことも意味する。 ◎ If multiple read/write transactions are attempting to access the same object store (i.e. if they have overlapping scope), the transaction that was created first must be the transaction which gets access to the object store first. Due to the requirements in the previous paragraph, this also means that it is the only transaction which has access to the object store until the transaction is finished.
- `~readwrite~tx$ %A の後に`作成-$された,~tx %B は、 %A と`視野$が重なる`保管庫$ %O があるならば, %A により書込された %O への変更を見ること。 前~項による要件に因り,これは、 %A が`終了-$するまで,[ %B は, %A の`視野$に入る どの`保管庫$にも~accessできない ]ことを意味する。 ◎ Any transaction created after a read/write transaction must see the changes written by the read/write transaction. So if a read/write transaction, A, is created, and later another transaction B, is created, and the two transactions have overlapping scopes, then B must see any changes made to any object stores that are part of that overlapping scope. Due to the requirements in the previous paragraph, this also means that the B transaction does not have access to any object stores in that overlapping scope until the A transaction is finished.
注記: 上述から、一般に,`~readwrite~tx$と, その後に作成された~txは、互いの視野が重なるならば,並列的に稼働できないことを意味する。 ◎ Generally speaking, the above requirements mean that any transaction which has an overlapping scope with a read/write transaction and which was created after that read/write transaction, can’t run in parallel with that read/write transaction.
~UAは、~starvationを防止するように,各~tx間に適度な公平さを確保し~MUST。 例えば,いくつもの`~readonly~tx$が絶え間なく開始される状況下で、`開始-$待ち`~readwrite~tx$を不定に待たせては~MUST_NOT。 ◎ User agents must ensure a reasonable level of fairness across transactions to prevent starvation. For example, if multiple read-only transactions are started one after another the implementation must not indefinitely prevent a pending read/write transaction from starting.
`索引付き~db~txを片付ける@ ときは、次を走らす — これは、片付けられた~txが[ 在れば ~T / 無ければ ~F ]を返す: ◎ To cleanup Indexed Database transactions, run these steps. They will return true if any transactions were cleaned up, or false otherwise.
- %結果 ~LET ~F ◎ If there are no transactions with cleanup event loop matching the current event loop, return false.
-
`~tx$のうち[ その`片付ける~event-loop$ ~EQ 現在の`~event-loop$ ]を満たす ~EACH( %~tx ) に対し: ◎ For each transaction with cleanup event loop matching the current event loop:
- %結果 ~SET ~T ◎ ↑↓
- %~tx の`作動中~flag$ ~SET ~OFF ◎ Unset the transaction's active flag.
- %~tx の`片付ける~event-loop$ ~SET ε ◎ Clear the transaction's cleanup event loop.
- ~RET %結果 ◎ Return true.
注記: この挙動は、 `HTML$r から呼出される。 それは、~scriptから~callされた `transaction()^m により作成された`~tx$は,~scriptが呼出した~taskが完了した時点で作動中でなくなることを確保する。 この手続きが走るのは、`~tx$ごとに高々 1 度限りになる。 ◎ This behavior is invoked by [HTML]. It ensures that transactions created by a script call to transaction() are deactivated once the task that invoked the script has completed. The steps are run at most once for each transaction.
2.7.2 昇格~tx
`~mode$が `versionchange$l にされた`~tx$を `昇格~tx@ ( `upgrade transaction^en )という。 ◎ An upgrade transaction is a transaction with mode "versionchange".
`昇格~tx$は、`~db$への`接続$が~openされた後,`昇格~txを稼働-$する手続きの間に、指定された`~version$dbが現在の`~version$dbより大きい場合に,自動的に作成される†。 この`~tx$は、 `upgradeneeded$et ~event~handlerの内側で`作動中$になる。 ◎ An upgrade transaction is automatically created when running the steps to run an upgrade transaction after a connection is opened to a database, if a version greater than the current version is specified. This transaction will be active inside the upgradeneeded event handler.
【† このとき以外に,`接続$に`専属する$`昇格~tx$が作成される機会はない。 したがってそれは、同じ接続に`専属する$他のどの`~tx$よりも先に`開始-$されることになる。 】
注記: `昇格~tx$は、`~db$内の[ `保管庫$ / `索引$ ]の[ 作成, 名前の変更, 削除 ]を可能化する。 ◎ An upgrade transaction enables the creation, renaming, and deletion of object stores and indexes in a database.
`昇格~tx$は、排他的である。 `~dbを~open$する手続きは、[ `昇格~tx$が`稼働して$いる間,~dbを~openしている`接続$ ]は,唯一に限られることを確保する。 同じ`~db$への他のすべての`接続$が~closeされるまでは、 `upgradeneeded$et ~eventは発火されず,したがって`昇格~tx$も開始されない。 これは、以前のすべての~txが`終了-$されることを確保する。 `昇格~tx$が稼働している限り、同じ`~db$への他の`接続$を~openしようとする試みは遅延され、同じ`接続$を利用するために `transaction()^m を~callして追加の~txを開始しようとする試みに対しては、例外が投出されることになる。 したがって,`昇格~tx$は、[ 他の~txが同時並行的に稼働しない ]ことに加え,稼働している間は[ 同じ`~db$に対し,他の~txは~queueされない ]ことを確保する。 ◎ An upgrade transaction is exclusive. The steps to open a database ensure that only one connection to the database is open when an upgrade transaction is running. The upgradeneeded event isn’t fired, and thus the upgrade transaction isn’t started, until all other connections to the same database are closed. This ensures that all previous transactions are finished. As long as an upgrade transaction is running, attempts to open more connections to the same database are delayed, and any attempts to use the same connection to start additional transactions by calling transaction() will throw an exception. Thus upgrade transactions not only ensure that no other transactions are running concurrently, but also ensure that no new transactions are queued against the same database as long as the transaction is running.
これは、`昇格~tx$が完了したなら,`~db$内の[ `保管庫$, `索引$ ]の集合は、後続のすべての`接続$, `~tx$の存続期間において,一定であり続けることを確保する。 ◎ This ensures that once an upgrade transaction is complete, the set of object stores and indexes in a database remain constant for the lifetime of all subsequent connections and transactions.
【 この仕様に現れる, `昇格~txの中@ という句は、[ `upgradeneeded$et ~eventにより呼出される~event~handlerの中 ]を意味する。 “昇格~txの外” という句は、その否定を意味する。 】
2.8. 要請
`~db$に対する各 非同期の`演算$は、 `要請@ ( `request^en )を利用して行われる。 どの %要請 も,ある一つの`演算$(以下, %演算 と記す)を表現し、次のものが結付けられる(括弧内は,対応する `IDBRequest!I ~interface~member ): ◎ Each asynchronous operation on a database is done using a request. Every request represents one operation.
- `~done~flag@ ( `readyState$m )
- %演算 が完了した(成功裡に終えた/失敗した/中止された)かどうかを指示する。 初期~時は ~OFF。 ◎ A request has a done flag which is initially unset.
- `~source@ ( `source$m )
- 【 %演算 の対象 — 次のいずれか:[ `保管庫~handle$/`索引~handle$/`~cursor$/ε ]。 %要請 の作成-時に設定され(設定されない場合は ε )、それ以降は変わらない。 】 ◎ A request has a source object.
- `結果@ ( `result$m )
- `~error@ ( `error$m )
- `~done~flag$が ~ON になるまでは~accessできない。 ~ON の時点で,どうなるかについては、下記に。 ◎ A request has a result and an error, neither of which are accessible until the done flag is set.
- `設置先~tx@ ( `transaction$m )
- 初期~時は ε 。 %要請 は、 %演算 を`非同期に実行する$手続きを用いて,`~tx$に `設置-@ される。 同時に, %要請 は設置先~txの`要請~list$に追加される。 ◎ A request has a transaction which is initially null. This will be set when a request is placed against a transaction using the steps to asynchronously execute a request.
`要請$が発行0されるときは、[ `~done~flag$ ~SET ~OFF ]にされた 新たな`要請$が返される。 `要請$が表現する `演算@ は、要請が非同期に実行する手続きの~instance — すなわち,[ 手続き, それに対する入力, その結果 ]の組 — である。
`要請$ %要請 がその`演算$の手続きを終えたときは、先ず[ %要請 の`~done~flag$ ~SET ~ON ]にされた上で、演算から返された %結果 に応じて:
-
~errorでない場合(演算は成功した):
- %要請 の`結果$は %結果 に設定され、 %要請 の`~error$は ε に設定される。
- %要請 に向けて `success$et ~eventが発火される。
-
~errorである場合(演算は失敗した):
- %要請 の`結果$は ε に設定され、 %要請 の`~error$は %結果 に設定される。
- %要請 に向けて `error$et ~eventが発火される。
`要請$の`親~標的を取得する$~algoは、要請の`設置先~tx$を返す。 ◎ A request’s get the parent algorithm returns the request’s transaction.
注記: 要請は概して,再利用されないが、例外もある。 `~cursor$が反復されるときは、その~cursorを~openするときに利用した同じ`要請$に向けて,反復の成功が報告される。 また,`昇格~tx$が必要とされる場合も、同じ`~open要請$が[ `upgradeneeded$et ~event, ~open演算~自身の最終~結果 ]の両者に利用される。 事例によっては、要請の`~done~flag$は ~OFF にされてから再び ~ON にされ,`結果$は変化する, あるいは`~error$が設定されることもある。 ◎ Requests are not typically re-used, but there are exceptions. When a cursor is iterated, the success of the iteration is reported on the same request object used to open the cursor. And when an upgrade transaction is necessary, the same open request is used for both the upgradeneeded event and final result of the open operation itself. In some cases, the request’s done flag will be unset then set again, and the result can change or error could be set insead.
2.8.1. ~open要請
`~open要請@ は、[ `接続$を~openする, あるいは`~db$を削除する ]ときに利用される,特別な型の`要請$である。 `~open要請$に対しては: ◎ An open request is a special type of request used when opening a connection or deleting a database.\
- [ `success$et, `error$et ]~eventに加え,進捗を指示する[ `blocked@et, `upgradeneeded@et ]~eventも発火され得る。 ◎ In addition to success and error events, blocked and upgradeneeded may be fired at an open request to indicate progress.
- その`~source$は常に ε である。 ◎ The source of an open request is always null.
- その`設置先~tx$は、 `upgradeneeded$et ~eventが発火されない限り, ε にされる。 ◎ The transaction of an open request is null unless an upgradeneeded event has been fired.
- その`親~標的を取得する$~algoは、 ~NULL を返す。 ◎ An open request’s get the parent algorithm returns null.
`~open要請$は `接続~queue@ にて処理される。 この~queueは、組 ( `生成元$, `名前$db ) に結付けられる,すべての`~open要請$を包含する†。 `接続~queue$に追加された各 要請は、順序どおりに処理され,次の要請が処理される前に完了され~MUST。 ~open要請は、【それが~openしようとしている~dbを~openしている】 他の`接続$により阻まれ得る — それらの接続が`~close$されるまで、その要請は完了せず,更なる要請は処理できないことになる。 ◎ Open requests are processed in a connection queue. The queue contains all open requests associated with an origin and a name. Requests added to the connection queue processed in order and each request must run to completion before the next request is processed. An open request may be blocked on other connections, requiring those connections to close before the request can complete and allow further requests to be processed.
【† 言い換えれば,接続~queueは、同じ`~db$(その生成元に`専属する$, かつ その名前を持つものとして一意に定まる)に対し,それを`~access先$とする`接続$を~openしようとする`要請$すべてからなる。 】
注記: `接続~queue$は、`~event-loop$に結付けられる`~task~queue$ではない — 要請は、すべての`閲覧文脈$の外側で処理されるので。 完了した`~open要請$向けの~eventは、依然として,要請を発行0した文脈~下の `~event-loop$に結付けられている`~task~queue$を通して送達される。 ◎ A connection queue is not a task queue associated with an event loop, as the requests are processed outside any specific browsing context. The delivery of events to completed open request still goes through a task queue associated with the event loop of the context where the request was made.
2.9. ~key範囲
`保管庫$や`索引$から一連の`~record$を検索取得するためには、[ 単独の`~key$, または`~key範囲$ ]を利用する。 `~key範囲@ とは、~keyに利用される ある~data型にわたる連続的な区間である。 ◎ Records can be retrieved from object stores and indexes using either keys or key ranges. A key range is a continuous interval over some data type used for keys.
各 `~key範囲$には、次のものが結付けられる(括弧内は、対応する `IDBKeyRange!I ~interface~member) 【これらは、作成-時に設定され,それ以降は変化しない】 :
- `下界@ ( `lower$m )
- `~key$, または ε 。 ◎ A key range has an associated lower bound (null or a key).
- `上界@ ( `upper$m )
- `~key$, または ε 。 ◎ A key range has an associated upper bound (null or a key).
- `下界open~flag@ ( `lowerOpen$m )
- ~flag値。 他が指定されない限り ~OFF とする。 ◎ A key range has an associated lower open flag. Unless otherwise stated it is unset.
- 【 `下界$ ~EQ ε の場合は、必ず ~ON にされる。 】
- `上界open~flag@ ( `upperOpen$m )
- ~flag値。 他が指定されない限り ~OFF とする。 ◎ A key range has an associated upper open flag. Unless otherwise stated it is unset.
- 【 `上界$ ~EQ ε の場合は、必ず ~ON にされる。 】
[ `下界$ ~GT~cmpkey `上界$ ]になっては~MUST_NOT。 ◎ A key range may have a lower bound equal to its upper bound. A key range must not have a lower bound greater than its upper bound.
`Only@ ( %key ) と記される,所与の`~key$ %key のみを包含する`~key範囲$は、次の様にされた`~key範囲$として定義される ⇒# `下界$ ~SET %key, `上界$ ~SET %key, `上界open~flag$ ~SET ~OFF, `下界open~flag$ ~SET ~OFF ◎ A key range containing only key has both lower bound and upper bound equal to key.
所与の`~key$ %key は、次の両~条件を満たすとき,`~key範囲$ %範囲 に `入る@ とされる: ◎ A key is in a key range if both of the following conditions are fulfilled:
-
次のいずれかの条件を満たす:
- %範囲 の`下界$ ~EQ ε
- %範囲 の`下界$ ~LT~cmpkey %key
- [ %範囲 の`下界$ ~EQ~cmpkey %key ]~AND[ %範囲 の`下界open~flag$ ~EQ ~OFF ]
-
次のいずれかの条件を満たす:
- %範囲 の`上界$ ~EQ ε
- %範囲 の`上界$ ~GT~cmpkey %key
- [ %範囲 の`上界$ ~EQ~cmpkey %key ]~AND[ %範囲 の`上界open~flag$ ~EQ ~OFF ]
注記: [ `下界$ / `上界$ ]は、`~key範囲$に`入る$とされる`~key$の[ “~~下限” / “~~上限” ]を与える。 [ `下界$ / `上界$ ]に対する ε は[ ~~下限/~~上限 ]が無いことを表す。
`下界$は、`下界open~flag$が ~OFF のとき, そのときに限り,`~key範囲$に`入る$。 `上界open~flag$についても同様になる。
◎ If the lower open flag of a key range is unset, the lower bound key of the key range is included in the range itself. ◎ If the lower open flag of a key range is set, the lower bound key of the key range is excluded from the range itself. ◎ If the upper open flag of a key range is unset, the upper bound key of the key range is included in the range itself. ◎ If the upper open flag of a key range is set, the upper bound key of the key range is excluded from the range itself.`全範囲@ とは、[ `下界$ ~EQ `上界$ ~EQ ε ]なる`~key範囲$である。 任意の`~key$に対し[ `~key$ ~IN `全範囲$ ]は真になる。 ◎ An unbounded key range is a key range that has both lower bound and upper bound equal to null. All keys are in an unbounded key range.
【 `全範囲$は `IDBKeyRange$I ~objとしては~instance化され得ない — ~modelにのみ存在する~objである。 】
`Range@ ( %値, %~NULL不可 ) は、所与の %値 で表現される`~key範囲$を返すか, または 例外を投出する: ◎ The steps to convert a value to a key range with value and optional null disallowed flag are as follows:
-
%値 に応じて:
- `~key範囲$である
- ~RET %値 ◎ If value is a key range, return value.
- ε
- ~NULL†
-
- ~IF [ %~NULL不可 ~NEQ ε ] ⇒ ~THROW `DataError$E
- ~RET `全範囲$
- その他
- ~RET `Only$( `Key$( %値 ) ) ? ◎ Let key be the result of running the steps to convert a value to a key with value. Rethrow any exceptions. ◎ If key is invalid, throw a "DataError" DOMException. ◎ Return a key range containing only key.
【† この手続きは、~key範囲を期待する引数(この仕様では,名前 %query の引数として記される)をとる~API~methodから呼び出される。 その引数が省略可能であって, ~NULL が渡された場合、特別に,引数が省略されたとき( ε )と同じに扱われることになる。 】
2.10. ~cursor
`~cursor@ は、ある~dbに`専属する$[ `索引$/`保管庫$ ]の中の ある範囲に入る~recordたちを,特定の方向に反復するために利用される。 ◎ A cursor is used to iterate over a range of records in an index or an object store in a specific direction.
`~cursor$ は、次のものを持つ(括弧内は、対応する `IDBCursor!I ~interface~member) — これらは、~cursorを作成する`要請$の`演算$の中で設定される:
- `要請@Cs
- ~cursorを作成させた`要請$。 【この項目は、この訳による補完。】
- `~tx@Cs
- ~cursorの`~source$Csが`専属する$`~tx$。 【この訳では、この用語は利用せず,単にこのように記す。】 ◎ A cursor has a transaction, the transaction that was active when the cursor was created.
- `範囲@Cs
- `~key範囲$。 ~cursorは、[ `~source$Cs↗内の`~record$のうち,`~key$がこの範囲に`入る$もの ]を反復対象にする。 ◎ A cursor has a range of records in either an index or an object store.
- 【 ~cursorの作成-時に指定されなかった場合、`全範囲$が指定されたものと見なされる。 】
- `~source@Cs ( `source$m )
- `保管庫~handle$, または`索引~handle$。 ~cursorは, ~source↗( ~sourceの`~access先$)の~record~listを反復対象にする。 ◎ A cursor has a source that indicates which index or an object store is associated with the records over which the cursor is iterating.
- 【 原文における`~source$Csは、[ `保管庫$, または`索引$ ]として定義されているが、~modelの記述を簡潔にするため,この訳では 上述のように代えている — ~cursorを利用するどの演算も,保管庫~handle/索引~handleを通した~accessを要しており、まわりくどい記述になっているので。 】
- `方向@Cs ( `direction$m )
-
次の二つを指示する:
- 反復-時に~cursorの`位置$Csを移動させる方向 — すなわち,`~record$たちを その`~key$の 昇順, 降順 いずれの順序で反復するか。 ~cursor初期~位置は[ 前者/後者 ]に応じて,`~source$Cs↗の[ 始端/終端 ]側に位置することになる。
- ~keyが重複する~recordがあるとき,最初のもの以外を飛ばすかどうか。
-
~cursorの`方向$Csは、次の値をとり得る:
- `next@l
- `~cursor$を`~source$Cs↗の始端~側から,`~key$の昇順に反復する。
- `prev@l
- `~cursor$を`~source$Cs↗の終端~側から,~keyの降順に反復する。
- `next$l, `prev$l のいずれも、反復-時には、`~key$が`等しい$もの†も含め,`範囲$Csに`入る$すべての~recordを得るべきである††。
- 【† 重複する~keyを伴う~record間の反復-順序については、`保管庫~位置$Csを見よ。 】【†† “べき” — `位置$Csの記述を見よ。 】
- `nextunique@l
- `~key$が互いに`等しい$~recordたちについては,それらのうち最初の~record以外は飛ばすことを除いて、 `next$l と同じ。
- `prevunique@l
- `~key$が互いに`等しい$~recordたちについては,それらのうち 最初の ~record以外は飛ばすことを除いて、 `prev$l と同じ。
- [ `nextunique$l / `prevunique$l ]に対しては、`~source$Cs↗が[ `保管庫$, または[ `一意~flag$Ix ~EQ ~ON ]なる`索引$ ]である場合の挙動は,[ `next$l / `prev$l ]と正確に同じになる。
- `位置@Cs
- `範囲$Csに`入る$どこかを指す†。 ~cursorが反復対象にしている~record~listは、~cursorの`範囲$Csが全部的に反復される前に変更されることもある。 これを取扱うため、~cursorは自身の`位置$Csを,~indexとしてではなく,前回に返した†~recordの`~key$として保守する。 ~cursorが次の~recordへ反復するよう請われたとき、`方向$Csが~keyの昇順なら、前回に反復した~recordの~key`より大きい$~keyを持つ~recordのうち,最小の`~key$を持つものを返すことになる††。 `方向$Csが~keyの降順なら、それとは逆に,前回に反復した~recordの~key`より小さい$~keyを持つ~recordのうち,最大の`~key$を持つものを返すことになる。 ◎ A cursor has a position within its range. It is possible for the list of records which the cursor is iterating over to change before the full range of the cursor has been iterated. In order to handle this, cursors maintain their position not as an index, but rather as a key of the previously returned record. For a forward iterating cursor, the next time the cursor is asked to iterate to the next record it returns the record with the lowest key greater than the one previously returned. For a backwards iterating cursor, the situation is opposite and it returns the record with the highest key less than the one previously returned.
- 【† 位置は、初期~時には,反復~順序における仮想の先頭( ε )をとるが、~cursorを作成するよう要請したときに,この位置のまま~APIに公開されることはない — `範囲$Csに入る~recordが無い場合、要請の`結果$は ~NULL になる。 】【 ~cursorがすべてを反復し終えて,次の~recordへの反復が試みられた場合、 ε に設定され,それ以上~反復できなくなる。 】【†† 索引における~keyの重複を無視するならば。 次項を見よ。 】
- `保管庫~位置@Cs
- `索引$においては、複数の~recordが同じ~keyを持つこともあり,`値$によっても整列されることから、`索引$を反復する~cursorについては,少しばかり複雑になる。 この場合、`~cursor$は,前回の反復にて索引~内に見出された`~record$の`値$を指示する,保管庫~位置も持つ†。 次の~recordを見出すときには、`位置$Csに加え,`保管庫~位置$Csも利用される。 ◎ For cursors iterating indexes the situation is a little bit more complicated since multiple records can have the same key and are therefore also sorted by value. When iterating indexes the cursor also has an object store position, which indicates the value of the previously found record in the index. Both position and the object store position are used when finding the next appropriate record.
- 【† すなわち,`参照先~record$の`~key$ — ゆえに “保管庫~位置” と称されている。 】
- `~key@Cs ( `key$m )
- ~cursorが最後に反復した`~record$の`~key$を表現する。 ◎ ↓
- 【 これは,実質的に`位置$Csの別名。 】
- `値@Cs ( `IDBCursorWithValue.value$m )
- ~cursorが最後に反復した`~record$の`値$†を表現する。 ◎ A cursor has a key and a value which represent the key and the value of the last iterated record.
- 【† `~source$Cs↗が`索引$の場合は`参照先~record$の値。 】
- `値取得済~flag@Cs
- ~ON は、[[ ~cursorを利用する`要請$ ]が`非同期に実行する$`演算$ ]が完了し,新たな ( `~key$Cs, `値$Cs ) を得た(新たな ( `位置$Cs, `保管庫~位置$Cs ) に移動した)ことを指示する。
- 【 新たな~cursorを取得した時点では、その前に,`範囲$Csに入る最初の~recordが検索取得されるので、この~flagも ~ON になる。 】
-
~ON は、~OFF の否定であり、したがって,次のいずれかを指示する:
- ~cursorを利用する`要請$が`非同期に実行する$`演算$は、完了していない。
- ~cursorは,その`範囲$Csに入るすべての~recordを反復し終えて,次の~recordへの反復が一度でも試みられた。
【 後者の場合のみ,[ `~key$Cs, `値$Cs ]は ε にされるので、 `key$m を調べれば前者と区別できる。 後者の場合、それ以上~cursorは利用できなくなる — 例えば `範囲$Csに入る新たな~recordが追加されても,`値取得済~flag$Csが ~ON に戻ることはない(そうしてから もう一度~反復を試みても,例外が投出されることになる)。 】
◎ A cursor has a got value flag. When this flag unset, the cursor is either in the process of loading the next value or it has reached the end of its range. When it is set, it indicates that the cursor is currently holding a value and that it is ready to iterate to the next one. - `実効~保管庫@Cs
- ~cursorの`~source$Cs↗が[ `保管庫$ならば それ/ `索引$ならば それが`専属する$`保管庫$ ]。 ◎ ↓
- `実効~key@Cs ( `primaryKey$m )
- ~cursorの`~source$Cs↗が[ `保管庫$ならば ~cursorの`位置$Cs / `索引$ならば ~cursorの`保管庫~位置$Cs ]。 ◎ If the source of a cursor is an object store, the effective object store of the cursor is that object store and the effective key of the cursor is the cursor’s position. If the source of a cursor is an index, the effective object store of the cursor is that index’s referenced object store and the effective key is the cursor’s object store position.
- `~key~only~flag@Cs
- ~cursorの`値$Csも~APIに公開されるかどうかを指示する。 他が言明されない限り ~OFF をとる。 ◎ A cursor also has a key only flag, that indicates whether the cursor’s value is exposed via the API. Unless stated otherwise it is unset.
- 【 ~OFF の場合、~cursorは `IDBCursorWithValue$I ~interfaceを実装することになる。 】
2.11. ~key生成器
`保管庫$の作成-時には、 `~key生成器@ を利用するようにも指定できる。 ~key生成器は、保管庫の中へ挿入される~record用の~keyが指定されていない場合に,それを生成するために利用される。 ◎ When a object store is created it can be specified to use a key generator. A key generator is used to generate keys for records inserted into an object store if not otherwise specified.
`~key生成器$は `現在の番号@ を持つ。 `現在の番号$は、`保管庫$の作成-時には 1 に設定され,常に[[ `最大の番号@ ~EQ 2 の 53 乗( 9007199254740992 ) ] + 1 ]以下の整数になる 【実際に利用される~keyは最大の番号~以下になる】 。 `現在の番号$は、~keyが生成される度に増分される。 また,明示的~keyを用いて特定の値に更新できる。 ◎ A key generator has a current number. The current number is always a positive integer less than or equal to 253 (9007199254740992) + 1. The initial value of a key generator's current number is 1, set when the associated object store is created. The current number is incremented as keys are generated, and may be updated to a specific value by using explicit keys.
注記: どの保管庫も,~~自前の`~key生成器$を利用する。 ある保管庫との相互作用が,他の保管庫の`~key生成器$に影響することは、決してない。 ◎ Every object store that uses key generators uses a separate generator. That is, interacting with one object store never affects the key generator of any other object store.
`現在の番号$に対する改変は、~db演算の一部と見なされる:
- 演算が何であれ、それが失敗して,それによる変更が復帰された場合、`現在の番号$も元の値に復帰される。
- `~tx$が中止された場合、~txの`視野$に入る各`保管庫$の`~key生成器$の`現在の番号$は,その~txの開始-前の値に復帰される。
`現在の番号$は、~db演算の結果が復帰される場合を除き,決して減少しない。 `保管庫$から`~record$を削除しようが, `IDBObjectStore.clear()$m ~methodを利用して全~recordを消去しようが、保管庫の`~key生成器$には決して影響しない。 ◎ The current number for a key generator never decreases, other than as a result of database operations being reverted. Deleting a record from an object store never affects the object store’s key generator. Even clearing all records from an object store, for example using the clear() method, does not affect the current number of the object store’s key generator.
`~record$を格納する~callにて明示的に`~key$が指定されていない場合、~keyは生成される。 ◎ When a record is stored and a key is not specified in the call to store the record, a key is generated.
`保管庫$ %保管庫 用の `~keyを生成-@ するときは、次を走らす: ◎ To generate a key for an object store store, run these steps:
- %生成器 ~LET %保管庫 の`~key生成器$ ◎ Let generator be the key generator associated with store.
- %~key ~LET %生成器 の`現在の番号$ ◎ Let key be generator’s current number.
- ~IF[ %~key ~GT `最大の番号$ ] ⇒ ~RET `失敗^i ◎ If key is greater than 253 (9007199254740992), then return failure.
- %生成器 の`現在の番号$ ~INCBY 1 ◎ Increase generator’s current number by 1.
- ~RET %~key ◎ Return key.
`~record$を格納する~callにて`~key$が明示的に指定された場合、`~key生成器$は更新され得る。 ◎ When a record is stored and a key is specified in the call to store the record, the associated key generator may be updated.
所与の %~key で`保管庫$ %保管庫 用の `~key生成器を可能なら更新する@ ときは、次を走らす: ◎ To possibly update the key generator for an object store store with key, run these steps:
- ~IF[ %~key の`種別$key ~NEQ `number$i ] ⇒ ~RET ◎ If the type of key is not number, abort these steps.
- %値 ~LET %~key の`値$key ◎ Let value be the value of key.
- %値 ~LET[ %値, `最大の番号$ ]の両者を超えない最大の整数 ◎ Let value be the minimum of value and 253 (9007199254740992). ◎ Let value be the largest integer not greater than value.
- %生成器 ~LET %保管庫 の`~key生成器$ ◎ Let generator be the key generator associated with store.
- ~IF[ %値 ~GTE %生成器 の`現在の番号$ ] ⇒ %生成器 の`現在の番号$ ~SET %値 + 1 ◎ If value is greater than or equal to generator’s current number, then set generator’s current number to value + 1.
注記: ~keyは、`保管庫$が`~key~path$Osを持つかどうかに応じて,次のいずれかにより指定できる:
- 持つ場合:[ 保管庫に格納する`~record$の`値$ ]の[ ~key~pathが指す部位にある~prop ]に~keyを設定する。
- 持たない場合:~recordを格納する~callの引数として,~keyを渡す。
指定された~keyが`現在の番号$に影響するのは、その`種別$keyが `number$i の場合に限られ、他の`種別$keyの~keyは影響しない — `string$i 値を `number$i 値に構文解析するような,暗黙的な変換の類は行われない。 また、 1 より小さい `number$i ~keyも,`現在の番号$より常に低いので影響しない。 ◎ Only specified keys of type number can affect the current number of the key generator. Keys of type date, array (regardless of the other keys they contain), binary, or string (regardless of whether they could be parsed as numbers) have no effect on the current number of the key generator. Keys of type number with value less than 1 do not affect the current number since they are always lower than the current number.
`現在の番号$が`最大の番号$を超えた下では、`~key生成器$を利用して新たな`~key$を生成させるような 後続のどの試みに対しても `ConstraintError$E 例外が投出される。 明示的~keyを指定すれば、依然として`~record$を保管庫に挿入できるが、`~key生成器$を再び利用するためには,保管庫を削除して新たに作成し直す他にない。 ◎ When the current number of a key generator reaches above the value 253 (9007199254740992) any subsequent attempts to use the key generator to generate a new key will result in a "ConstraintError" DOMException. It is still possible to insert records into the object store by specifying an explicit key, however the only way to use a key generator again for such records is to delete the object store and create a new one.
注記: この上限は、`最大の番号$を超える整数は~JS `Number$js では一意に表現できないことによる。 例えば~JSにおいては、[ `9007199254740992 + 1 === 9007199254740992^c ]になる。 ◎ This limit arises because integers greater than 9007199254740992 cannot be uniquely represented as ECMAScript Numbers. As an example, 9007199254740992 + 1 === 9007199254740992 in ECMAScript.
`~key生成器$を普通に利用している限り、この上限は問題にはならない。 新たな~keyを毎秒 1000 回~生成し続けても,この上限に達するのは 285000 年後である。 ◎ As long as key generators are used in a normal fashion this limit will not be a problem. If you generate a new key 1000 times per second day and night, you won’t run into this limit for over 285000 years.
~~要約すると、`~key生成器$を持つような保管庫に対しては:
- 最初に生成される~keyは(他の `number$i ~keyが明示的に挿入されない限り)常に 1 になる。
- 生成される~keyは、常に,保管庫~内の最大の `number$i ~keyより大きい,正の整数になる。
- 同じ保管庫に対し,同じ~keyが二度~生成されることは、~txが巻戻されない限り,決してない。
3. 例外
この文書が利用する各種 例外は,特定の名前の `DOMException$I である。 例外の名前と その旧来の~code値などの~propは `WEBIDL$r 【~error名~一覧】 にて定義されている。 ◎ Each of the exceptions used in this document is a DOMException with a specific type. The exception types and properties such as legacy code value are defined in [WEBIDL].
以下の一覧に、この文書が利用する 例外~名, および その用法を述べる: ◎ The table below lists the DOMExceptions used in this document along with a description of the exception type’s usage.
例外~名 | 意味 |
---|---|
`AbortError@E | `要請$は中止された。 ◎ A request was aborted. |
`ConstraintError@E | ~txにおける変異~演算は、拘束が充足されないため,失敗した。 ◎ A mutation operation in the transaction failed because a constraint was not satisfied. |
`DataCloneError@E | 格納しようと試みた~dataは、内部~有構造~clone~algoにより~cloneできなかった。 ◎ The data being stored could not be cloned by the internal structured cloning algorithm. |
`DataError@E | 演算に供された~dataは、要件を満たしていない。 ◎ Data provided to an operation does not meet requirements. |
`InvalidAccessError@E | ~obj上に妥当でない演算が遂行された。 ◎ An invalid operation was performed on an object. |
`InvalidStateError@E | 所与の演算は~obj上に許容されない, あるいは許容されない時機に~callされた。 または、すでに削除された/除去された~source~objに対し要請が発行0された。 ◎ An operation was called on an object on which it is not allowed or at a time when it is not allowed, or if a request is made on a source object that has been deleted or removed. |
`NotFoundError@E | 要請された~db~objを見出せなかったため、演算は失敗した。 ◎ The operation failed because the requested database object could not be found. |
`QuotaExceededError@E | 残りの蓄積~~容量が十分でないため、あるいは,蓄積~quotaに到達したが,利用者が~dbへの容量追加を辞退しため、演算は失敗した。 ◎ The operation failed because there was not enough remaining storage space, or the storage quota was reached and the user declined to give more space to the database. |
`SyntaxError@E | 渡された %keyPath 引数は,`妥当な~key~path$でない。 ◎ The keyPath argument contains an invalid key path. |
`ReadOnlyError@E | `~readonly~tx$において,変異~演算が試みられた。 ◎ The mutating operation was attempted in a read-only transaction. |
`TransactionInactiveError@E | 現在 `作動中$でない/すでに`終了-$した~txに対し,要請が設置された。 ◎ A request was placed against a transaction which is currently not active, or which is finished. |
`UnknownError@E | 演算は、~db自身に関係ない, かつ 他の~errorにも該当しない事由で,失敗した。 ◎ The operation failed for reasons unrelated to the database itself and not covered by any other errors. |
`VersionError@E | 既存の~versionより低い~versionで~dbを~openしようと試みられた。 ◎ An attempt was made to open a database using a lower version than the existing version. |
注記: 複数の Indexed DB 演算が,同じ型の~errorを投出したり、単独の演算であっても,複数の事由に対し同じ型の~errorを投出し得るので、実装には、より~~詳細な~messageを供して,~errorを~debugし易くすることが奨励される。 ◎ Given that multiple Indexed DB operations can throw the same type of error, and that a even single operation can throw the same type of error for multiple reasons, implementations are encouraged to provide more specific messages to enable developers to identify the cause of errors.
4. ~API
各種~API~methodは、それを~callした~threadを阻むことなく返す。 すべての非同期的な演算は、即時に `IDBRequest$I ~instanceを返す。 この~objは、初期~時には,演算の結果について,いかなる情報も包含しない。 情報が可用になったなら、要請に向けて~eventが発火され,情報は `IDBRequest$I ~instanceの各種~属性を通して可用になる。 ◎ The API methods return without blocking the calling thread. All asynchronous operations immediately return an IDBRequest instance. This object does not initially contain any information about the result of the operation. Once information becomes available, an event is fired on the request and the information becomes available through the properties of the IDBRequest instance.
`~db~access~task源@ が、これらの~taskの`~task源$である。 ◎ The task source for these tasks is the database access task source.
4.1. `IDBRequest^I ~interface
`IDBRequest$I ~interfaceが、`~db$や, それに専属する各種~objに対する非同期的な`要請$の結果に~accessする手段を,`~event~handler~IDL属性$ `HTML$r を利用して供する。 ◎ The IDBRequest interface provides the means to access results of asynchronous requests to databases and database objects using event handler IDL attributes [HTML].
~dbに対し`演算$を要請するような どの~methodも,[ ~eventを通して,要請している~appに`結果$を~~返信する ]ような, `IDBRequest$I ~objを返す。 すなわち,`演算$は非同期に実行される。 この設計は、どの`~db$に対しても,いくつもの要請が同時に作動中になり得ることを意味する。 ◎ Every method for making asynchronous requests returns an IDBRequest object that communicates back to the requesting application through events. This design means that any number of requests can be active on any database at a time.
[`Exposed$=(Window,Worker)]
interface `IDBRequest@I : `EventTarget$I {
readonly attribute any `result$m;
readonly attribute `DOMException$I? `error$m;
readonly attribute (`IDBObjectStore$I or `IDBIndex$I or `IDBCursor$I)? `source$m;
readonly attribute `IDBTransaction$I? `transaction$m;
readonly attribute `IDBRequestReadyState$I `readyState$m;
// ~event~handler:
attribute `EventHandler$I `onsuccess$m;
attribute `EventHandler$I `onerror$m;
};
enum `IDBRequestReadyState@I {
`pending$l,
`done$l
};
- %request . `result$m
- %request が完了している場合、それが[ 成功したならば その`結果$ / 失敗したならば `undefined^js ]を返す。 完了していない場合、 `InvalidStateError$E を投出する。 ◎ When a request is completed, returns the result, or undefined if the request failed. Throws a "InvalidStateError" DOMException if the request is still pending.
- %request . `error$m
- %request が完了している場合、それが[ 成功したならば ~NULL / 失敗したならば `~error$ ( `DOMException$I ) ]を返す。 完了していない場合、 `InvalidStateError$E を投出する。 ◎ When a request is completed, returns the error (a DOMException), or null if the request succeeded. Throws a "InvalidStateError" DOMException if the request is still pending.
- %request . `source$m
- %request は`~open要請$である場合、~NULL を返す。 他の場合、 %request の`~source$( `IDBObjectStore$I / `IDBIndex$I / `IDBCursor$I )を返す。 ◎ Returns the IDBObjectStore, IDBIndex, or IDBCursor the request was made against, or null if is was an open request.
- %request . `transaction$m
- %request の`設置先~tx$( `IDBTransaction$I )を返す。 ただし, %request は`~open要請$である場合は、それにより~openされた`~db$の`昇格~tx$dbが`稼働して$[ いるならば それ / いなければ ~NULL ]を返す。 ◎ Returns the IDBTransaction the request was made within. If this as an open request, then it returns an upgrade transaction while it is running, or null otherwise.
- %request . `readyState$m
- %request が完了して[ いなければ `pending$l / いれば `done$l ]を返す。 ◎ Returns "pending" until a request is complete, then returns "done".
- `result@m
-
取得子は、~MUST_RUN:
- ~IF[ 此れの`~done~flag$ ~EQ ~OFF ] ⇒ ~THROW `InvalidStateError$E
- ~RET [ 此れの`結果$ ~NEQ ε ならば それ / ~ELSE_(すなわち此れの`~error$ ~NEQ ε ) `undefined^js ]
【 結果 ~NEQ ε の場合でも,結果~自身は `undefined^js にもなり得る( `IDBObjectStore.get()$m の注記を見よ)。 】
◎ The result attribute’s getter must throw an "InvalidStateError" DOMException if the done flag is unset. Otherwise, the attribute’s getter must return the result of the request, or undefined if the request resulted in an error. - `error@m
-
取得子は、~MUST_RUN:
- ~IF[ 此れの`~done~flag$ ~EQ ~OFF ] ⇒ ~THROW `InvalidStateError$E
- ~RET[ 此れの`~error$ ~NEQ ε ならば それ / ~ELSE_(すなわち此れの`結果$ ~NEQ ε ならば) ~NULL ]
- `source@m
- 取得子は、[ 此れの`~source$ ~NEQ ε ならば それ / ~ELSE_ ~NULL ]を返さ~MUST。 ◎ The source attribute’s getter must return the source of the request, or null if no source is set.
- `transaction@m
- 取得子は、此れの[ `設置先~tx$ ~NEQ ε ならば それ / ~ELSE_ ~NULL ]を返さ~MUST。 `IDBFactory.open()$m から返される`要請$など,`設置先~tx$が無い要請からは、 ~NULL も返され得る。 ◎ The transaction attribute’s getter must return the transaction of the request. This property can be null for certain requests, such as for requests returned from open().
- `readyState@m
- 取得子は、此れの`~done~flag$に応じて[ ~OFF ならば `pending@l / ~ON ならば `done@l ]を返さ~MUST。 ◎ The readyState attribute’s getter must return "pending" if the done flag is unset, and "done" otherwise.
- `onsuccess@m
- `success$et ~event用の~event~handler。 ◎ The onsuccess attribute is the event handler for the success event.
- `onerror@m
- `error$et ~event用の~event~handler。 ◎ The onerror attribute is the event handler for the error event.
`IDBDatabase$I 上の `~open要請$を返す各種~methodは、[ `blocked$et, `upgradeneeded$et ]~eventを~listenできるように拡張された~interfaceを利用する。 ◎ Methods on IDBDatabase that return a open request use an extended interface to allow listening to the blocked event and upgradeneeded event.
[`Exposed$=(Window,Worker)]
interface `IDBOpenDBRequest@I : `IDBRequest$I {
// ~event~handler:
attribute `EventHandler$I `onblocked$m;
attribute `EventHandler$I `onupgradeneeded$m;
};
- `onblocked@m
- `blocked$et ~event用の~event~handler。 ◎ The onblocked attribute is the event handler for the blocked event.
- `onupgradeneeded@m
- `upgradeneeded$et ~event用の~event~handler。 ◎ The onupgradeneeded attribute is the event handler for the upgradeneeded event.
4.2. ~event~interface
この仕様は、次の~custom~interfaceによる~eventを発火する: ◎ This specification fires events with the following custom interfaces:
[`Exposed$=(Window,Worker), Constructor(DOMString %type, optional `IDBVersionChangeEventInit$I %eventInitDict)] interface `IDBVersionChangeEvent@I : `Event$I { readonly attribute unsigned long long `oldVersion$m; readonly attribute unsigned long long? `newVersion$m; }; dictionary `IDBVersionChangeEventInit@I : `EventInit$I { unsigned long long `oldVersion@m = 0; unsigned long long? `newVersion@m = null; };
- `oldVersion@m
- ~dbの以前の`~version$dbを返す。 ◎ The oldVersion attribute getter returns the previous version of the database.
- `newVersion@m
- ~dbの新たな`~version$dbを返す。 ただし、~dbが削除されつつあるときは ~NULL になる。 `昇格~txを稼働-$する手続きを見よ。 ◎ The newVersion attribute getter returns the new version of the database, or null if the database is being deleted. See the steps to run an upgrade transaction.
~eventは、~DOM標準の`~eventの構築-法$による定義に従って構築される。 ◎ Events are constructed as defined in DOM Standard §constructing-events.
%標的 に向けて `~version変更~eventを発火する@ ときは、所与の ( 名前 %e, %旧~version, %新~version ) に対し,次を走らす: ◎ To fire a version change event named e at target given oldVersion and newVersion, run these steps:
- %~event ~LET `IDBVersionChangeEvent$I を用いて`~eventを作成-$した結果 ◎ Let event be the result of creating an event using IDBVersionChangeEvent.
- %~event の各種~属性を次のように初期化する ⇒# `type$m ~SET %e, `bubbles$m ~SET ~F, `cancelable$m ~SET ~F, `oldVersion$m ~SET %旧~version, `newVersion$m ~SET %新~version ◎ • Set event’s type attribute to e. • Set event’s bubbles and cancelable attributes to false. • Set event’s oldVersion attribute to oldVersion. • Set event’s newVersion attribute to newVersion.
- ~RET `Dispatch$( %標的, %~event ) ◎ Let legacyOutputDidListenersThrowFlag be unset. ◎ Dispatch event at target with legacyOutputDidListenersThrowFlag. ◎ Return legacyOutputDidListenersThrowFlag.
注記: この~algoの結果は利用されないこともある。 ◎ The return value of this algorithm is not always used.
【 各種~event型 】
便宜のため、この訳では,この仕様にて利用される各種~event型を以下に要約する:
この仕様の~eventの発火-先は、[ `要請$/`~tx$/`接続$ ]のいずれかである。 ~eventは、`親~標的を取得する$~algoを通して,複数の~objに伝播する場合もあることに注意。 親~標的は、[ `~open要請$に対しては ~NULL / 他の`要請$に対しては その`設置先~tx$ / `~tx$に対しては それが`専属する$`接続$ / `接続$に対しては ~NULL ]になる。
- `success@et
- `要請$が成功したときに,その要請に向けて発火される。
- `error@et
- 何らかの~errorにより`要請$が失敗したときに,その要請に向けて発火される。
- `versionchange$et
- `~version変更~event$の記述を見よ。
- `abort@et
- `~tx$が~errorまたは `abort()^m により`中止-$されたときに,その~txに向けて発火される。
- `close@et
- `接続$が 例外的な状況で~closeされた ときに,その接続に向けて発火される。
- `complete@et
- `~tx$が`~commit$されたときに,その~txに向けて発火される。
- `blocked$et
- 他の`接続$がまだ `~close済み$i でないために,[ `~dbを~open$する / `~dbを削除-$する ]`要請$が阻まれたとき、その要請に向けて発火される。
- `upgradeneeded$et
- `~db$を~openしたとき`昇格~tx$が生じたときに,その`~open要請$に向けて発火される。
4.3. `IDBFactory^I ~interface
`~db$~objは、 `IDBFactory$I ~interface上の各種~methodを通して~accessされる。 この~interfaceを実装する単独の~objは、 Indexed DB 演算を~supportする環境の大域~scopeに存在する。 ◎ Database objects are accessed through methods on the IDBFactory interface. A single object implementing this interface is present in the global scope of environments that support Indexed DB operations.
partial interface mixin `WindowOrWorkerGlobalScope!I { [`SameObject$] readonly attribute `IDBFactory$I `indexedDB$m; };
- `indexedDB@m
- この属性は、索引付き~dbの能力に~accessするための仕組みを,~appに供する。 ◎ The indexedDB attribute provides applications a mechanism for accessing capabilities of indexed databases.
[`Exposed$=(Window,Worker)] interface `IDBFactory@I { [`NewObject$] `IDBOpenDBRequest$I `open$m( DOMString %name, optional [`EnforceRange$] unsigned long long %version ); [`NewObject$] `IDBOpenDBRequest$I `deleteDatabase$m( DOMString %name ); short `cmp$m( any %first, any %second ); };
- %request = `indexedDB$m . `open$m(%name)
- `名前$db %name の`~db$への`接続$を,該当する`~db$が[ 存在するならば その現在の`~version$db / 存在しないならば`~version$db 1 ]で~openするよう要請する。 成功した場合の %request ( `IDBOpenDBRequest$I )の `result$m は、その~dbへの`接続$になる。 ◎ Attempts to open a connection to the named database with the current version, or 1 if it does not already exist. If the request is successful request’s result will be the connection.
- %request = `indexedDB$m . `open$m(%name, %version)
-
`名前$db %name の`~db$への`接続$を,指定した~version %version で~openするよう要請する。 該当する~db %db が存在する場合,その`~version$dbが:
- %version より低い場合、[ %db を~openしている, かつ `versionchange$et ~eventに呼応して %db を~closeしていない ]`接続$が他にあるならば、要請は`阻まれ$,それらすべてが~closeされてから昇格が生じることになる。
- %version より高い場合、要請は失敗することになる。
成功した場合の %request ( `IDBOpenDBRequest$I )の `result$m は、当の`接続$になる。
◎ Attempts to open a connection to the named database with the specified version. If the database already exists with a lower version and there are open connections that don’t close in response to a versionchange event, the request will be blocked until all they close, then an upgrade will occur. If the database already exists with a higher version the request will fail. If the request is successful request’s result will be the connection. - %request = `indexedDB$m . `deleteDatabase$m(%name)
- 名前 %name の`~db$を削除するよう要請する。 該当する~db %db が存在する場合、[ %db を~openしている, かつ `versionchange$et ~eventに呼応して %db を~closeしていない ]`接続$があるならば,要請は`阻まれ$ることになる。 成功した場合の %request の `result$m は、 ~NULL になる。 ◎ Attempts to delete the named database. If the database already exists and there are open connections that don’t close in response to a versionchange event, the request will be blocked until all they close. If the request is successful request’s result will be null.
- `open(name, version)@m
-
被呼出時には、~MUST_RUN: ◎ The open(name, version) method, when invoked, must run these steps:
- ~IF[ %version ~EQ 0 ] ⇒ ~THROW `TypeError$js ◎ If version is 0 (zero), throw a TypeError.
- %生成元 ~LET 此れへの~accessに利用された大域~scope( `WindowOrWorkerGlobalScope$I )の`生成元$ ◎ Let origin be the origin of the global scope used to access this IDBFactory.
- ~IF[ %生成元 は`不透明な生成元$である ] ⇒ ~THROW `SecurityError$E ◎ If origin is an opaque origin, throw a "SecurityError" DOMException and abort these steps.
- %要請 ~LET 新たな`~open要請$ ◎ Let request be a new open request.
-
次の手続きを`並列的$に走らす: ◎ Run these steps in parallel:
-
%結果 ~LET 次を入力に `~dbを~open$した結果 ⇒# %生成元 ~SET %生成元, %名前 ~SET %name, %~version ~SET %version, %要請 ~SET %要請 ◎ Let result be the result of running the steps to open a database, with origin, name, version if given and undefined otherwise, and request.
注記: 名前 %name の`~db$が存在しなければ、新たな`~db$が作成される。 %version が与えられていない場合、接続は,[ 既存の~dbに対しては その`~version$dbを変更することなく / 新たな~dbに対しては その`~version$dbを 1 にして ]~openすることになる。 ◎ What happens if version is not given? ◎ If version is not given and a database with that name already exists, a connection will be opened without changing the version. If version is not given and no database with that name exists, a new database will be created with version equal to 1.
-
次を走らす`~taskを~queueする$: ◎ Queue a task to run these steps:
- %要請 の ⇒# `~done~flag$ ~SET ~ON, `結果$ ~SET ε, `~error$ ~SET ε ◎ ↓
-
~IF[ %結果 は~errorである ]:
- %要請 の`~error$ ~SET %結果
- %要請 に向けて,名前 `error$et の`~eventを発火する$ — 次のように初期化して ⇒# `bubbles$m 属性 ~SET ~T, `cancelable$m 属性 ~SET ~T
-
~ELSE:
- %要請 の`結果$ ~SET %結果
- %要請 に向けて,名前 `success$et の`~eventを発火する$
上の`~dbを~open$する手続きが`昇格~txを稼働-$させた場合、 `success$et ~eventの発火は,その昇格~txが完了した後に行われ~MUST。†
◎ Otherwise, set request’s result to result, set request’s done flag, and fire an event named success at request. If the steps above resulted in an upgrade transaction being run, then firing the "success" event must be done after the upgrade transaction completes.注記: †最後の要件は、別の~versionへの昇格が起こりつつある場合に,最初に`接続$上に `success$et ~eventを発火して、~scriptが[ `versionchange$et ~event用の~listenerを登録する機会 ]を得られるようにするためにある。 【?】 ◎ The last requirement is to ensure that in case another version upgrade is about to happen, the success event is fired on the connection first so that the script gets a chance to register a listener for the versionchange event.
注記: ここで,通常の[ `~success~eventを発火する$ / `~error~eventを発火する$ ]手続きを適用しないのは、要請の`設置先~tx$がないためである(その手続きは,`設置先~tx$を配送-前に作動化して配送-後に作動中でなくする)。 ◎ Why aren’t the steps to fire a success event or fire an error event used? ◎ There is no transaction associated with the request (at this point), so those steps — which activate an associated transaction before dispatch and deactivate the transaction after dispatch — do not apply.
-
- ~RET %要請 を表現する,新たな `IDBOpenDBRequest$I ~obj ◎ Return a new IDBOpenDBRequest object for request.
- `deleteDatabase(name)@m
-
被呼出時には、~MUST_RUN: ◎ The deleteDatabase(name) method, when invoked, must run these steps:
- %生成元 ~LET 此れへの~accessに利用された大域~scope( `WindowOrWorkerGlobalScope$I )の`生成元$ ◎ Let origin be the origin of the global scope used to access this IDBFactory.
- ~IF[ %生成元 は`不透明な生成元$である ] ⇒ ~THROW `SecurityError$E ◎ If origin is an opaque origin, throw a "SecurityError" DOMException and abort these steps.
- %要請 ~LET 新たな`~open要請$ ◎ Let request be a new open request.
-
次の手続きを`並列的$に走らす: ◎ Run these steps in parallel:
- %結果 ~LET 次を入力に `~dbを削除-$した結果 ⇒# %生成元 ~SET %生成元, %名前 ~SET %name, %要請 ~SET %要請 ◎ Let result be the result of running the steps to delete a database, with origin, name, and request.
-
次を走らす`~taskを~queueする$: ◎ Queue a task to run these steps:
- %要請 の ⇒# `~done~flag$ ~SET ~ON, `結果$ ~SET ε, `~error$ ~SET ε ◎ ↓
-
~IF[ %結果 は~errorである ]:
- %要請 の`~error$ ~SET %結果
- %要請 に向けて,名前 `error$et の`~eventを発火する$ — 次のように初期化して ⇒# `bubbles$m 属性 ~SET ~T, `cancelable$m 属性 ~SET ~T
-
~ELSE:
- %要請 の`結果$ ~SET ε
- %要請 に向けて`~version変更~eventを発火する$( `success$et, %結果, ~NULL )
注記: この時点では、要請の`設置先~tx$はないので、通常の[ `~success~eventを発火する$ / `~error~eventを発火する$ ]手続き(それは,`設置先~tx$を配送-前に作動化して配送-後に作動中でなくする)は,適用できない。 また、ここでの `success$et ~eventは `IDBVersionChangeEvent$I であり, `oldVersion^m, `newVersion^m も含んでいる。 ◎ Why aren’t the steps to fire a success event or fire an error event used? ◎ There is no transaction associated with the request, so those steps — which activate an associated transaction before dispatch and deactivate the transaction after dispatch — do not apply. ◎ Also, the success event here is a IDBVersionChangeEvent which includes the oldVersion and newVersion details.
- ~RET %要請 を表現する,新たな `IDBOpenDBRequest$I ~obj ◎ Return a new IDBOpenDBRequest object for request.
- %result = `indexedDB$m . `cmp$m(%key1, %key2)
- 2 個の値を`~key$として比較した結果を,次で与える数として返す ⇒# %key1, %key2 が`等しい$ならば 0, %key1 は %key2 `より小さい$ならば −1, %key1 は %key2 `より大きい$ならば 1 ◎ Compares two values as keys. Returns -1 if key1 precedes key2, 1 if key2 precedes key1, and 0 if the keys are equal.
- %key1, %key2 のいずれかが`~key$として妥当でない場合、 `DataError$E が投出される。 ◎ Throws a "DataError" DOMException if either input is not a valid key.
- `cmp(first, second)@m
-
被呼出時には、~MUST_RUN: ◎ The cmp(first, second) method, when invoked, must run these steps:
- %a ~LET `Key$( %first ) ? ◎ Let a be the result of running the steps to convert a value to a key with first. Rethrow any exceptions. ◎ If a is invalid, throw a "DataError" DOMException.
- %b ~LET `Key$( %second ) ? ◎ Let b be the result of running the steps to convert a value to a key with second. Rethrow any exceptions. ◎ If b is invalid, throw a "DataError" DOMException.
- ~RET `Compare$( %a, %b ) ◎ Return the results of running the steps to compare two keys with a and b.
4.4. `IDBDatabase^I ~interface
`IDBDatabase$I ~interfaceは、`~db$への`接続$を表現する。 ◎ The IDBDatabase interface represents a connection to a database.
[ 次の両条件を満たしている`接続$ ]を表現する `IDBDatabase$I ~objは、~garbage収集されては~MUST_NOT:
- `状態$Cn ~EQ `~open中$i
- [ `abort$et, `error$et, `versionchange$et ]いずれかの型の~event~listenerが登録されている
`IDBDatabase$I ~objを~garbage収集するときは、その前に,それが表現する`接続$は`~close$され~MUST。
◎ An IDBDatabase object must not be garbage collected if its associated connection’s close pending flag is unset and it has one or more event listeners registers whose type is one of abort, error, or versionchange. If an IDBDatabase object is garbage collected, the associated connection must be closed.
[`Exposed$=(Window,Worker)]
interface `IDBDatabase@I : `EventTarget$I {
readonly attribute DOMString `name$m;
readonly attribute unsigned long long `version$m;
readonly attribute `DOMStringList$I `objectStoreNames$m;
[`NewObject$] `IDBTransaction$I `transaction$m(
(DOMString or sequence<DOMString>) %storeNames,
optional `IDBTransactionMode$I %mode = `readonly$l
);
void `close$m();
[`NewObject$] `IDBObjectStore$I `createObjectStore$m(
DOMString %name,
optional `IDBObjectStoreParameters$I %options
);
void `deleteObjectStore$m(
DOMString %name
);
// ~event~handler:
attribute `EventHandler$I `onabort$m;
attribute `EventHandler$I `onclose$m;
attribute `EventHandler$I `onerror$m;
attribute `EventHandler$I `onversionchange$m;
};
dictionary `IDBObjectStoreParameters@I {
(DOMString or sequence<DOMString>)? `keyPath@m = null;
boolean `autoIncrement@m = false;
};
- %connection . `name$m
- 接続先~dbの`名前$dbを返す。 ◎ Returns the name of the database.
- %connection . `version$m
- 接続先~dbの`~version$dbを返す。 ◎ Returns the version of the database.
- `name@m
- 取得子は、此れ↗の`名前$dbを返さ~MUST。 この属性は、`値を保持し続ける$。 ◎ The name attribute’s getter must return the name of the connected database. The attribute must return this name even if the close pending flag is set on the connection. In other words, the value of this attribute stays constant for the lifetime of the IDBDatabase instance.
- `version@m
- 取得子は、此れの`~version$Cnを返さ~MUST。 ◎ The version attribute’s getter must return this connection’s version.
- 注記: この属性は、此れの`状態$Cn ~EQ `~open中$i の間は,此れ↗の`~version$dbと同じ値を返し、それ以降も同じ`値を保持し続ける$。 ◎ Is this the same as the database's version? ◎ As long as the connection is open, this is the same as the connected database’s version. But once the connection has closed, this attribute will not reflect changes made with a later upgrade transaction.
- %connection . `objectStoreNames$m
- 接続先`~db$に`専属する$`保管庫$たちの`名前$Osからなる~listを返す。 ◎ Returns a list of the names of object stores in the database.
- %store = %connection . `createObjectStore$m(%name [, %options])
- 接続先`~db$に`専属する$, かつ,`名前$Os %name の, %options を伴う新たな`保管庫$を作成した上で、それを`~access先$とする 新たな `IDBObjectStore$I を返す。 ◎ Creates a new object store with the given name and options and returns a new IDBObjectStore.
- `昇格~txの外$で~callされた場合、 `InvalidStateError$E を投出する。 ◎ Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.
- %connection . `deleteObjectStore$m(%name)
- 接続先`~db$に`専属する$,`名前$Os %name の`保管庫$を削除する。 ◎ Deletes the object store with the given name.
- `昇格~txの外$で~callされた場合、 `InvalidStateError$E を投出する。 ◎ Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.
- `objectStoreNames@m
- 取得子は、 `SortedList$( 此れの`保管庫~集合$Cn内の すべての`保管庫$の`名前$Os ) を返さ~MUST。 ◎ The objectStoreNames attribute’s getter must return a DOMStringList associated with a sorted list of the names of the object stores in this connection's object store set.
- この属性は、此れの`状態$Cn ~EQ `~open中$i の間は,此れ↗に専属する`保管庫$たちの`名前$Osからなる~listと同じ値を返し、それ以降も同じ`値を保持し続ける$。 ◎ Is this the same as the database's object store names? ◎ As long as the connection is open, this is the same as the connected database’s object store names. But once the connection has closed, this attribute will not reflect changes made with a later upgrade transaction.
- `createObjectStore(name, options)@m
-
被呼出時には、~MUST_RUN: ◎ The createObjectStore(name, options) method, when invoked, must run these steps:
- %~tx ~LET 此れ↗の`昇格~tx$db ◎ Let database be the database associated with this connection. ◎ Let transaction be database’s upgrade transaction if it is not null,\
-
~IF[ %~tx ~EQ ε ] ⇒ ~THROW `InvalidStateError$E
【 %~tx が此れ↗に`専属しない$場合も例外を投出するべきでは? 】
◎ or throw an "InvalidStateError" DOMException otherwise. - ~IF[ %~tx は`作動中$でない ] ⇒ ~THROW `TransactionInactiveError$E ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %keyPath ~LET %options の `keyPath^m ~member値 ◎ Let keyPath be options’s keyPath member if it is not undefined or null, or null otherwise.
- ~IF[ %keyPath ~NEQ ~NULL ]~AND[ %keyPath は`妥当な~key~path$でない ] ⇒ ~THROW `SyntaxError$E ◎ If keyPath is not null and is not a valid key path, throw a "SyntaxError" DOMException.
- ~IF[ 此れの`保管庫~集合$Cn内に[ `名前$Os ~EQ %name ]なる`保管庫$がある ] ⇒ ~THROW `ConstraintError$E ◎ If an object store named name already exists in database throw a "ConstraintError" DOMException.
- %自動生成 ~LET %options の `autoIncrement^c ~member値 ◎ Let autoIncrement be set if options’s autoIncrement member is true, or unset otherwise.
- ~IF[ %自動生成 ~EQ ~T ] ⇒ ~IF[ %keyPath ~EQ 空~DS値 ]~OR[ %keyPath は~SeqDS型である ] ⇒ ~THROW `InvalidAccessError$E ◎ If autoIncrement is set and keyPath is an empty string or any sequence (empty or otherwise), throw an "InvalidAccessError" DOMException.
- %保管庫 ~LET 次の様にされた,新たな`保管庫$ ⇒# 此れ↗に`専属する$, `~record~list$Os ~SET 空~list, `名前$Os ~SET %name, `~key生成器$を[ %自動生成 ~EQ ~T ならば持つ / ~ELSE_ 持たない ], `~key~path$Os ~SET [ %keyPath ~NEQ ~NULL ならば %keyPath / ~ELSE_ ε ] ◎ Let store be a new object store in database. Set the created object store’s name to name. If autoIncrement is set, then the created object store uses a key generator. If keyPath is not null, set the created object store’s key path to keyPath.
- 此れの`保管庫~集合$Cnに %保管庫 を追加する 【この段は、この訳による補完】
- ~RET 次の様にされた,新たな`保管庫~handle$ %H ⇒# %H↗ ~EQ %保管庫, %H は %~tx に`専属する$ ◎ Return a new object store handle associated with store and transaction.
- この~methodは、新たな`保管庫$を作成した上で,それを`~access先$とする新たな`保管庫~handle$を返す。 この~methodを~callできるのは、`昇格~txの中$からに限られることに注意。 ◎ This method creates and returns a new object store with the given name in the connected database. Note that this method must only be called from within an upgrade transaction.
- この~methodは,此れ上の `objectStoreNames$m 属性を同期的に改変する。 ◎ This method synchronously modifies the objectStoreNames property on the IDBDatabase instance on which it was called.
-
実装によっては、この~methodが~~呼出し元に~~制御を返して,~db内に`保管庫$を作成する演算を~queueした後に,問題になる可能性がある。 例えば、[ 新たに作成された`保管庫$についての~metadataを,~dbに非同期に挿入する所 ],あるいは[ ~quota事由から,利用者に許可を請う必要があり得る所 ]で。 そうなり得る場合でも、実装は:
- 依然として `IDBObjectStore$I ~objを作成して返さ~MUST。
-
加えて,`保管庫$の作成ingに失敗したときは、[ 失敗の事由に適切な~error名† ]を入力に `~txを中止-$する手続きを行って, %~tx を`中止-$し~MUST。
† 例えば ~quota事由に因り`保管庫$の作成ingに失敗した場合は、 `QuotaExceededError$E を利用し~MUST。
- `deleteObjectStore(name)@m
-
被呼出時には、~MUST_RUN: ◎ The deleteObjectStore(name) method, when invoked, must run these steps:
- %~tx ~LET 此れ↗の`昇格~tx$db ◎ Let database be the database associated with this connection. ◎ Let transaction be database’s upgrade transaction if it is not null,\
-
~IF[ %~tx ~EQ ε ] ⇒ ~THROW `InvalidStateError$E
【 %~tx が此れ↗に`専属しない$場合も例外を投出するべきでは? 】
◎ or throw an "InvalidStateError" DOMException otherwise. - ~IF[ %~tx は`作動中$でない ] ⇒ ~THROW `TransactionInactiveError$E ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %保管庫 ~LET 此れの`保管庫~集合$Cn内の[ `名前$Os ~EQ %name ]なる`保管庫$ ◎ Let store be the object store named name in database,\
- ~IF[ %保管庫 ~EQ ε ] ⇒ ~THROW `NotFoundError$E ◎ or throw a "NotFoundError" DOMException if none.
- 此れの`保管庫~集合$Cnから %保管庫 を除去する ◎ Remove store from this connection’s object store set.
- ~IF[ %~tx に`専属する$, かつ %保管庫 を`~access先$とする`保管庫~handle$ %H がある ] ⇒ %H の`索引~集合$OsHを空にする ◎ If there is an object store handle associated with store and transaction, remove all entries from its index set.
- 此れ↗内の %保管庫 を( %保管庫 に`専属する$`索引$たちも込みで)破壊する ◎ Destroy store.
- この~methodは、この`接続$↗に専属している,名前 %name の`保管庫$を破壊する。 この~methodを~callできるのは、`昇格~txの中$からに限られることに注意。 ◎ This method destroys the object store with the given name in the connected database. Note that this method must only be called from within an upgrade transaction.
- この~methodは,此れ上の `objectStoreNames$m 属性を同期的に改変する。 ◎ This method synchronously modifies the objectStoreNames property on the IDBDatabase instance on which it was called.
- %transaction = %connection . `transaction$m(%scope [, %mode = "readonly"])
- %connection に`専属する$新たな`~tx$を返す。 %mode ( `readonly$l / `readwrite$l )が,その`~mode$を与え、 %scope ( 1 個の`名前$Os, または 一連の`名前$Osからなる配列)が,その`視野$を与える。 ◎ Returns a new transaction with the given mode ("readonly" or "readwrite") and scope which can be a single object store name or an array of names.
- %connection . `close$m()
- %connection を~closeする — ~closeし終えるのは、 %connection に`専属する$すべての`~tx$が,稼働し終えた時点になる。 ◎ Closes the connection once all running transactions have finished.
- `transaction(storeNames, mode)@m
-
被呼出時には、~MUST_RUN: ◎ The transaction(storeNames, mode) method, when invoked, must run these steps:
- ~IF[ 此れ↗の`昇格~tx$dbは`稼働して$いる ] ⇒ ~THROW `InvalidStateError$E ◎ If a running upgrade transaction is associated with the connection, throw an "InvalidStateError" DOMException.
- ~IF[ 此れの`状態$Cn ~NEQ `~open中$i ] ⇒ ~THROW `InvalidStateError$E ◎ If the connection's close pending flag is set, throw an "InvalidStateError" DOMException.
- %視野 ~LET %storeNames の型に応じて ⇒# ~SeqDSならば,その中の一意な文字列からなる集合(集合なので,重複するものは一つにする)/ ~DSならば,その文字列のみからなる集合 ◎ Let scope be the set of unique strings in storeNames if it is a sequence, or a set containing one string equal to storeNames otherwise.
- ~IF[ %視野 内に,此れの`保管庫~集合$Cn内のどの`保管庫$の`名前$Osにも一致しないものがある ] ⇒ ~THROW `NotFoundError$E ◎ If any string in scope is not the name of an object store in the connected database, throw a "NotFoundError" DOMException.
- ~IF[ %視野 は 空である ] ⇒ ~THROW `InvalidAccessError$E ◎ If scope is empty, throw an "InvalidAccessError" DOMException.
- ~IF[ %mode ~NIN { `readonly$l, `readwrite$l } ] ⇒ ~THROW `TypeError$js ◎ If mode is not "readonly" or "readwrite", throw a TypeError.
- %~tx ~LET 次のようにされた`新たな~tx$ ⇒# `視野$ ~SET [ 此れの`保管庫~集合$Cn内の, %視野 により指示される`保管庫$たち ]からなる集合, `~mode$ ~SET %mode, `専属する$`接続$ ~SET 此れ ◎ Let transaction be a newly created transaction with connection, mode and the set of object stores named in scope.
- %~tx の`片付ける~event-loop$ ~SET 現在の`~event-loop$ ◎ Set transaction’s cleanup event loop to the current event loop.
- ~RET %~tx を表現する `IDBTransaction$I ~obj ◎ Return an IDBTransaction object representing transaction.
- 注記: 作成された~txは、その`存続期間$の規則に従う。 ◎ The created transaction will follow the lifetime rules.
- `close()@m
-
被呼出時には、~MUST_RUN: ◎ The close() method, when invoked, must run these steps:
- 次を入力に `~db接続を~close$する ⇒ %接続 ~SET 此れ ◎ Run the steps to close a database connection with this connection.
- `onabort@m
- `abort$et ~event用の~event~handler。 ◎ The onabort attribute is the event handler for the abort event.
- `onclose@m
- `close$et ~event用の~event~handler。 ◎ The onclose attribute is the event handler for the close event.
- `onerror@m
- `error$et ~event用の~event~handler。 ◎ The onerror attribute is the event handler for the error event.
- `onversionchange@m
- `versionchange$et ~event用の~event~handler。 ◎ The onversionchange attribute is the event handler for the versionchange event.
4.5. `IDBObjectStore^I ~interface
`IDBObjectStore$I ~interfaceは、`保管庫~handle$を表現する。 ◎ The IDBObjectStore interface represents an object store handle.
[`Exposed$=(Window,Worker)] interface `IDBObjectStore@I { attribute DOMString `name$m; readonly attribute any `keyPath$m; readonly attribute `DOMStringList$I `indexNames$m; [`SameObject$] readonly attribute `IDBTransaction$I `transaction$m; readonly attribute boolean `autoIncrement$m; [`NewObject$] `IDBRequest$I `put$m( any %value, optional any %key ); [`NewObject$] `IDBRequest$I `add$m( any %value, optional any %key ); [`NewObject$] `IDBRequest$I `delete$m( any %query ); [`NewObject$] `IDBRequest$I `clear$m(); [`NewObject$] `IDBRequest$I `get$m( any %query ); [`NewObject$] `IDBRequest$I `getKey$m( any %query ); [`NewObject$] `IDBRequest$I `getAll$m( optional any %query, optional [`EnforceRange$] unsigned long %count ); [`NewObject$] `IDBRequest$I `getAllKeys$m( optional any %query, optional [`EnforceRange$] unsigned long %count ); [`NewObject$] `IDBRequest$I `count$m( optional any %query ); [`NewObject$] `IDBRequest$I `openCursor$m( optional any %query, optional `IDBCursorDirection$I %direction = "next" ); [`NewObject$] `IDBRequest$I `openKeyCursor$m( optional any %query, optional `IDBCursorDirection$I %direction = "next" ); `IDBIndex$I `index$m( DOMString %name ); [`NewObject$] `IDBIndex$I `createIndex$m( DOMString %name, (DOMString or sequence<DOMString>) %keyPath, optional `IDBIndexParameters$I %options ); void `deleteIndex$m( DOMString %name ); }; dictionary `IDBIndexParameters@I { boolean `unique@m = false; boolean `multiEntry@m = false; };
- %store . `name$m
- %store↗ の`名前$Osを返す。 ◎ Returns the name of the store.
- %store . `name$m = %newName
- %store↗ の`名前$Osを %newName に更新する。 ◎ Updates the name of the store to newName.
- `昇格~txの外$で~callされた場合、 `InvalidStateError$E が投出される。 ◎ Throws "InvalidStateError" DOMException if not called within an upgrade transaction.
- %store . `keyPath$m
- %store↗ の`~key~path$Os ~NEQ ε ならば それ / ~ELSE_ ~NULL を返す。 ◎ Returns the key path of the store, or null if none.
- %list . `indexNames$m
- %store↗ に`専属する$`索引$たちの`名前$Ixからなる~listを返す。 ◎ Returns a list of the names of indexes in the store.
- %store . `transaction$m
- %store が`専属する$`~tx$を返す。 ◎ Returns the associated transaction.
- %store . `autoIncrement$m
- %store↗ が`~key生成器$を[ 持つならば ~T / 持たないならば ~F ]を返す。 ◎ Returns true if the store has a key generator, and false otherwise.
- `name@m
- 取得子は、此れの`名前$OsHを返さ~MUST。 ◎ The name attribute’s getter must return this object store handle’s name.
- 注記: この属性は、此れが`専属する$~txが`終了-$されるまでは,此れ↗の`名前$Osと同じ値を返し、それ以降も同じ`値を保持し続ける$。 ◎ Is this the same as the object store's name? ◎ As long as the transaction has not finished, this is the same as the associated object store’s name. But once the transaction has finished, this attribute will not reflect changes made with a later upgrade transaction.
-
設定子は、~MUST_RUN: ◎ The name attribute’s setter must run these steps:
- `CheckState$( 此れ, `versionchange^l ) ? ◎ Let name be the given value. ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ 変則* If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not an upgrade transaction, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %name ~LET 与えられた値 ◎ ↑
- ~IF[ 此れの`名前$OsH ~EQ %name ] ⇒ ~RET ◎ If store’s name is equal to name, terminate these steps.
- ~IF[ 此れが`専属する$`接続$の`保管庫~集合$Cnに[ `名前$Os ~EQ %name ]なる`保管庫$がある ] ⇒ ~THROW `ConstraintError$E ◎ If an object store named name already exists in store’s database, throw a "ConstraintError" DOMException.
- 此れ↗の`名前$Os ~SET %name ◎ Set store’s name to name.
- 此れの`名前$OsH ~SET %name ◎ Set this object store handle’s name to name.
- `keyPath@m
- 取得子は、此れ↗の`~key~path$Os %P に応じて,[ %P ~EQ ε ならば ~NULL / ~ELSE_ `WEBIDL$r に従って %P を[ %P は文字列ならば ~DS型 / %P は文字列の~listならば ~SeqDS型 ]に変換した結果 ]を返さ~MUST。 この属性は、`値を保持し続ける$。 ◎ The keyPath attribute’s getter must return this object store handle's object store's key path, or null if none. The key path is converted as a DOMString (if a string) or a sequence<DOMString> (if a list of strings), per [WEBIDL].
- 返される値は、此れの作成-時に利用した~instanceと同じではない。 しかしながら,この属性が~obj(すなわち, `Array$js )を返す場合、毎回~同じ~instanceを返す。 返された~objの~prop値を変更しても,此れに効果を及ぼすことはない。 ◎ The returned value is not the same instance that was used when the object store was created. However, if this attribute returns an object (specifically an Array), it returns the same object instance every time it is inspected. Changing the properties of the object has no effect on the object store.
- `indexNames@m
- 取得子は、 `SortedList$( 此れの`索引~集合$OsH内の すべての`索引$の`名前$Ix ) を返さ~MUST。 ◎ The indexNames attribute’s getter must return a DOMStringList associated with a sorted list of the names of indexes in this object store handle's index set.
- 注記: この属性は、此れが`専属する$~txが`終了-$されるまでは,此れ↗に専属する`索引$たちの名前からなる~listと同じ値を返し、それ以降も同じ`値を保持し続ける$。 ◎ Is this the same as object store's list of index names? ◎ As long as the transaction has not finished, this is the same as the associated object store’s list of index names. But once the transaction has finished, this attribute will not reflect changes made with a later upgrade transaction.
- `transaction@m
- 取得子は、此れが`専属する$~txを返さ~MUST。 ◎ The transaction attribute’s getter must return this object store handle’s transaction.
- `autoIncrement@m
- 取得子は、[ 此れ↗の`~key生成器$ ~EQ ε ならば ~F / ~ELSE_ ~T ]を返さ~MUST。 この属性は、`値を保持し続ける$。 ◎ The autoIncrement attribute’s getter must return true if this object store handle’s object store has a key generator, and false otherwise.
以下に挙げる~methodは、[ `~readonly~tx$の中で~callされた場合は `ReadOnlyError$E / `~tx$が`作動中$でないときに~callされた場合は `TransactionInactiveError$E ]を投出する。 ◎ The following methods throw a "ReadOnlyError" DOMException if called within a read-only transaction, and a "TransactionInactiveError" DOMException if called when the transaction is not active.
- %request = %store . `put$m(%value [, %key])
- %request = %store . `add$m(%value [, %key])
- %store↗ 内に新たな`~record$ { %key : %value } を追加するよう要請する。 ◎ Adds or updates a record in store with the given value and key.
- %store↗ が`~key~path$Osを持つ場合、 %key は省略する必要がある — さもなければ `DataError$E が投出される。 【この場合の~keyは, %value から`~key~path$Osを用いて抽出される】 ◎ If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown.
-
%store↗ 内に`~key$ %key を持つ`~record$がすでに存在する場合:
- `add()$m に対しては、新たな~recordで置換されることになる(すなわち,~recordの値が更新される)。
- `add()$m に対しては、要請は失敗し, %request の `IDBRequest.error$m は `ConstraintError$E 例外に設定されることになる。
- 成功した場合の %request の `result$m は、追加した(置換した)`~record$の`~key$になる。 ◎ If successful, request’s result will be the record's key.
- %request = %store . `delete$m(%query)
- %store↗ の`~record~list$Osから[ %query が`表現する~key範囲$に入る~recordたち ]を削除するよう要請する。 ◎ Deletes records in store with the given key or in the given key range in query.
- 成功した場合の %request の `result$m は、`undefined^js になる。 ◎ If successful, request’s result will be undefined.
- %request = %store . `clear$m()
- %store↗ の`~record~list$Osを空にするよう要請する。 ◎ Deletes all records in store.
- 成功した場合の %request の `result$m は、 `undefined^js になる。 ◎ If successful, request’s result will be undefined.
- `put(value, key)@m
-
被呼出時には、~MUST_RUN: ◎ The put(value, key) method, when invoked, must run these steps:
- `CheckState$( 此れ, `readwrite^l ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException. ◎ If transaction is a read-only transaction, throw a "ReadOnlyError" DOMException.
- %keyPath ~LET 此れ↗の`~key~path$Os
- %生成器 ~LET 此れ↗の`~key生成器$
- ~IF[ %keyPath ~NEQ ε ]~AND[ %key ~NEQ ε ] ⇒ ~THROW `DataError$E ◎ If store uses in-line keys and key was given, throw a "DataError" DOMException.
- ~IF[ %keyPath ~EQ ε ]~AND[ %key ~EQ ε ]~AND[ %生成器 ~EQ ε ] ⇒ ~THROW `DataError$E ◎ If store uses out-of-line keys and has no key generator and key was not given, throw a "DataError" DOMException.
-
~IF[ %key ~NEQ ε ] ⇒ %key ~LET `Key$( %key ) ? ◎ If key was given, then: • Let r be the result of running the steps to convert a value to a key with key. Rethrow any exceptions. • If r is invalid, throw a "DataError" DOMException. • Let key be r.
- %clone ~LET `Clone$( %value ) ? ◎ Let targetRealm be a user-agent defined Realm. ◎ Let clone be a clone of value in targetRealm. Rethrow any exceptions. ◎ Why create a copy of the value? ◎ The value is serialized when stored. Treating it as a copy here allows other algorithms in this specification to treat it as an ECMAScript value, but implementations can optimize this if the difference in behavior is not observable.
-
~IF[ %keyPath ~NEQ ε ]:
- %抽出~key ~LET `Extract$( %clone, %keyPath, %生成器 ) ?
- ~IF[ %抽出~key ~NEQ ε ] ⇒ %key ~SET %抽出~key
- ~ELIF[ `~keyを値の中に注入できるか検査する$( %clone, %keyPath ) の結果 ~EQ ~F ] ⇒ ~THROW `DataError$E
- %演算 ~SET 次を入力に `保管庫に~recordを格納する$`演算$ ⇒# %保管庫 ~SET 此れ↗, %値 ~SET %clone, %key ~SET %key, %上書不可~flag ~SET ~OFF ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to store a record into an object store as operation, using store, the clone as value, key, and with the no-overwrite flag unset.
- `add(value, key)@m
-
被呼出時には、~MUST_RUN: ◎ The add(value, key) method, when invoked, must run these steps:
- `CheckState$( 此れ, `readwrite^l ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException. ◎ If transaction is a read-only transaction, throw a "ReadOnlyError" DOMException.
- %keyPath ~LET 此れ↗の`~key~path$Os
- %生成器 ~LET 此れ↗の`~key生成器$
- ~IF[ %keyPath ~NEQ ε ]~AND[ %key ~NEQ ε ] ⇒ ~THROW `DataError$E ◎ If store uses in-line keys and key was given, throw a "DataError" DOMException.
- ~IF[ %keyPath ~EQ ε ]~AND[ %key ~EQ ε ]~AND[ %生成器 ~EQ ε ] ⇒ ~THROW `DataError$E ◎ If store uses out-of-line keys and has no key generator and key was not given, throw a "DataError" DOMException.
-
~IF[ %key ~NEQ ε ] ⇒ %key ~LET `Key$( %key ) ? ◎ If key was given, then: • Let r be the result of running the steps to convert a value to a key with key. Rethrow any exceptions. • If r is invalid, throw a "DataError" DOMException. • Let key be r.
- %clone ~LET `Clone$( %value ) ? ◎ Let targetRealm be a user-agent defined Realm. ◎ Let clone be a clone of value in targetRealm. Rethrow any exceptions. ◎ Why create a copy of the value? ◎ The value is be serialized when stored. Treating it as a copy here allows other algorithms in this specification to treat it as an ECMAScript value, but implementations can optimize this if the difference in behavior is not observable.
-
~IF[ %keyPath ~NEQ ε ]:
- %抽出~key ~LET `Extract$( %clone, %keyPath, %生成器 ) ?
- ~IF[ %抽出~key ~NEQ ε ] ⇒ %key ~SET %抽出~key
- ~ELIF[ `~keyを値の中に注入できるか検査する$( %clone, %keyPath ) の結果 ~EQ ~F ] ⇒ ~THROW `DataError$E
- %演算 ~SET 次を入力に `保管庫に~recordを格納する$`演算$ ⇒# %保管庫 ~SET 此れ↗, %値 ~SET %clone, %key ~SET %key, %上書不可~flag ~SET ~ON ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to store a record into an object store as operation, using store, clone as value, key, and with the no-overwrite flag set.
- `delete(query)@m
-
被呼出時には、~MUST_RUN: ◎ The delete(query) method, when invoked, must run these steps:
- `CheckState$( 此れ, `readwrite^l ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException. ◎ If transaction is a read-only transaction, throw a "ReadOnlyError" DOMException.
- %範囲 ~LET `Range$( %query, `~NULL不可^i ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query and null disallowed flag set. Rethrow any exceptions.
- %演算 ~SET 次を入力に `保管庫から~recordを削除する$`演算$ ⇒# %保管庫 ~SET 此れ↗, %範囲 ~SET %範囲 ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to delete records from an object store as operation, using store and range.
- %query ~parameterは、削除する`~record$たちの~keyを識別する `~key$/`~key範囲$ をとり得る。 ◎ The query parameter may be a key or an IDBKeyRange identifying the records keys to be deleted.
- 注記: 他の~methodと違って、この~methodの %query 引数は, 省略可能でなく, また~NULL 値も許容されない(すなわち,`全範囲$は指定できない)。 これは、小さな~bugにより,保管庫の中を全~消去する~riskを抑制するためである。 ◎ Unlike other methods which take keys or key ranges, this method does not allow null to be given as key. This is to reduce the risk that a small bug would clear a whole object store.
- `clear()@m
-
被呼出時には、~MUST_RUN: ◎ The clear() method, when invoked, must run these steps:
- `CheckState$( 此れ, `readwrite^l ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException. ◎ If transaction is a read-only transaction, throw a "ReadOnlyError" DOMException.
- %演算 ~SET 次を入力に `保管庫の中を消去する$`演算$ ⇒ %保管庫 ~SET 此れ↗ ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to clear an object store as operation, using store.
以下に挙げる~methodは、`~tx$が`作動中$でないときに~callされた場合は `TransactionInactiveError$E を投出する。 ◎ The following methods throw a "TransactionInactiveError" DOMException if called when the transaction is not active.
- %request = %store . `get$m(%query)
- %store↗ の`~record~list$Os内の[ %query が`表現する~key範囲$に入る~recordたち ]のうち,最初の~recordの`値$を検索取得するよう要請する。 ◎ Retrieves the value of the first record matching the given key or key range in query.
- 成功した場合の %request の `result$m は、該当する~recordが[ あれば その`値$/ なければ `undefined^js ]になる。 ◎ If successful, request’s result will be the value, or undefined if there was no matching record.
- %request = %store . `getKey$m(%query)
- %store↗ の`~record~list$Os内の[ %query が`表現する~key範囲$に入る~recordたち ]のうち,最初の~recordの`~key$を検索取得するよう要請する。 ◎ Retrieves the key of the first record matching the given key or key range in query.
- 成功した場合の %request の `result$m は、該当する~recordが[ あれば その`~key$/ なければ `undefined^js ]になる。 ◎ If successful, request’s result will be the key, or undefined if there was no matching record.
- %request = %store . `getAll$m(%query [, %count])
- %store↗ の`~record~list$Os内の[ %query が`表現する~key範囲$に入る~recordたち ]のうち,最初から %count 個までの~recordの`値$たちを検索取得するよう要請する。 ◎ Retrieves the values of the records matching the given key or key range in query (up to count if given).
- 成功した場合の %request の `result$m は、一連の`値$からなる `Array$js になる。 ◎ If successful, request’s result will be an Array of the values.
- %request = %store . `getAllKeys$m(%query [, %count])
- %store↗ の`~record~list$Os内の[ %query が`表現する~key範囲$に入る~recordたち ]のうち,最初から %count 個までの~recordの`~key$たちを検索取得するよう要請する。 ◎ Retrieves the keys of records matching the given key or key range in query (up to count if given).
- 成功した場合の %request の `result$m は、一連の`~key$からなる `Array$js になる。 ◎ If successful, request’s result will be an Array of the keys.
- %request = %store . `count$m(%query)
- %store↗ の`~record~list$Os内の[ %query が`表現する~key範囲$に入る~recordたち ]の総数を得るよう要請する。 ◎ Retrieves the number of records matching the given key or key range in query.
- 成功した場合の %request の `result$m は、得られた総数になる。 ◎ If successful, request’s result will be the count.
- `get(query)@m
-
被呼出時には、~MUST_RUN: ◎ The get(query) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
-
%範囲 ~LET `Range$( %query, `~NULL不可^i ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query and null disallowed flag set. Rethrow any exceptions.
- %演算 ~SET 次を入力に `範囲に入る最初の~entryを検索取得する$`演算$ ⇒# %対象 ~SET 此れ↗, %範囲 ~SET %範囲, %取得演算 ~SET [ %record → ! `StructuredDeserialize$jA( %record の`値$, `現在の~Realm$ ) ] ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to retrieve a value from an object store as operation, using the current Realm as targetRealm, store and range.
- %query ~parameterは、検索取得する`~record$を識別する `~key$/`~key範囲$ をとり得る。 範囲が指定された場合、~methodは,その範囲に入る最初の既存の値を検索取得する。 ◎ The query parameter may be a key or an IDBKeyRange identifying the record to be retrieved. If a range is specified, the method retrieves the first existing value in that range.
- 注記: この~methodによる要請の`結果$は、所与の~keyを伴う~recordが存在しない場合も, `値$が `undefined^js の~recordが存在する場合も, `undefined^js 値になる。 両者を区別する必要があるときは、同じ~keyで `openCursor()$m を利用できる — その`結果$は、~recordが存在しなければ ~NULL になる一方で,存在するときは[ `値$Cs ~SET `undefined^js† ]にされた`~cursor$になる。 【† この訳では、内部処理~modelにおいては,値 ε により,そのような~recordが存在する場合とを区別している。】 ◎ This method produces the same result if a record with the given key doesn’t exist as when a record exists, but has undefined as value. If you need to tell the two situations apart, you can use openCursor() with the same key. This will return a cursor with undefined as value if a record exists, or no cursor if no such record exists.
- `getKey(query)@m
-
被呼出時には、~MUST_RUN: ◎ The getKey(query) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query, `~NULL不可^i ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query and null disallowed flag set. Rethrow any exceptions.
- %演算 ~SET 次を入力に `範囲に入る最初の~entryを検索取得する$`演算$ ⇒# %対象 ~SET 此れ↗, %範囲 ~SET %範囲, %取得演算 ~SET [ %record → `Value1$( %record の`~key$ ) ] ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to retrieve a key from an object store as operation, using store and range.
- %query ~parameterは、検索取得する`~record$の~keyを識別する `~key$/`~key範囲$ をとり得る。 範囲が指定された場合、~methodは,その範囲に入る最初の既存の~keyを検索取得する。 ◎ The query parameter may be a key or an IDBKeyRange identifying the record key to be retrieved. If a range is specified, the method retrieves the first existing key in that range.
- `getAll(query, count)@m
-
被呼出時には、~MUST_RUN: ◎ The getAll(query, count) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
-
%範囲 ~LET `Range$( %query ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query. Rethrow any exceptions.
- %演算 ~SET 次を入力に `範囲に入る~entryたちを検索取得する$`演算$ ⇒# %対象 ~SET 此れ↗, %範囲 ~SET %範囲, %取得演算 ~SET [ %record → ! `StructuredDeserialize$jA( %record の`値$, `現在の~Realm$ ) ], %count ~SET %count ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to retrieve multiple values from an object store as operation, using the current Realm as targetRealm, store, range, and count if given.
- %query ~parameterは、検索取得する`~record$たちを識別する `~key$/`~key範囲$ をとり得る。 ~NULL または省略時には,`全範囲$が利用される。 %count が指定されていて,範囲に入る~record数がそれを超える場合,最初から %count 個までが検索取得される。 ◎ The query parameter may be a key or an IDBKeyRange identifying the records to be retrieved. If null or not given, an unbounded key range is used. If count is specified and there are more than count records in range, only the first count will be retrieved.
- `getAllKeys(query, count)@m
-
被呼出時には、~MUST_RUN: ◎ The getAllKeys(query, count) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
-
%範囲 ~LET `Range$( %query ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query. Rethrow any exceptions.
- %演算 ~SET 次を入力に `範囲に入る~entryたちを検索取得する$`演算$ ⇒# %対象 ~SET 此れ↗, %範囲 ~SET %範囲, %取得演算 ~SET [ %record → `Value1$( %record の`~key$ ) ], %count ~SET %count ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to retrieve multiple keys from an object store as operation, using store, range, and count if given.
- %query ~parameterは、検索取得する`~record$たちの~keyを識別する `~key$/`~key範囲$ をとり得る。 ~NULL または省略時には,`全範囲$が利用される。 %count が指定されていて,範囲に入る~key数がそれを超える場合,最初から %count 個までが検索取得される。 ◎ The query parameter may be a key or an IDBKeyRange identifying the records keys to be retrieved. If null or not given, an unbounded key range is used. If count is specified and there are more than count keys in range, only the first count will be retrieved.
- `count(query)@m
-
被呼出時には、~MUST_RUN: ◎ The count(query) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query. Rethrow any exceptions.
- %演算 ~SET 次を入力に `範囲に入る~recordを数える$`演算$ ⇒# %source ~SET 此れ↗, %範囲 ~SET %範囲 ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to count the records in a range as operation, with source and range.
- %query ~parameterは、検索取得する`~record$たちの~keyを識別する `~key$/`~key範囲$ をとり得る。 ~NULL または省略時には,`全範囲$が利用される。 ◎ The query parameter may be a key or an IDBKeyRange identifying the records keys to be counted. If null or not given, an unbounded key range is used.
以下に挙げる~methodは、`~tx$が`作動中$でないときに~callされた場合は `TransactionInactiveError$E を投出する。 ◎ The following methods throw a "TransactionInactiveError" DOMException if called when the transaction is not active.
- %request = %store . `openCursor$m([%query [, %direction = "next"]])
- [ %store↗ の`~record~list$Os内の[ %query が`表現する~key範囲$( %query が~NULL ならば`全範囲$)に入る~recordたち ]を,`方向$Cs %direction で反復する`~cursor$ ]を作成するよう要請する。 ◎ Opens a cursor over the records matching query, ordered by direction. If query is null, all records in store are matched.
- 成功した場合の %request の `result$m は、範囲に入る~recordが[ なければ ~NULL / あれば 反復-順で最初の~recordを指している `IDBCursorWithValue$I ]になる。 ◎ If successful, request’s result will be an IDBCursorWithValue pointing at the first matching record, or null if there were no matching records.
- %request = %store . `openKeyCursor$m([%query [, %direction = "next"]])
- [ %store↗ の`~record~list$Os内の[ %query が`表現する~key範囲$( %query が~NULL ならば`全範囲$)に入る~recordたち ]を,`方向$Cs %direction で反復する`~cursor$ ]を作成するよう要請する。 作成される`~cursor$の`~key~only~flag$Csは ~ON になる(~cursorは、~recordの~keyのみを取得する)。 ◎ Opens a cursor with key only flag set over the records matching query, ordered by direction. If query is null, all records in store are matched.
- 成功した場合の %request の `result$m は、範囲に入る~recordが[ なければ ~NULL / あれば 反復-順で最初の~recordを指している `IDBCursor$I ]になる。 ◎ If successful, request’s result will be an IDBCursor pointing at the first matching record, or null if there were no matching records.
- `openCursor(query, direction)@m
-
被呼出時には、~MUST_RUN: ◎ The openCursor(query, direction) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query. Rethrow any exceptions.
- %演算 ~SET 次を入力に `~cursorを作成-$する`演算$ ⇒# %source ~SET 此れ, %方向 ~SET %direction, %範囲 ~SET %範囲, %~key~only~flag ~SET ~OFF ◎ Let cursor be a new cursor with transaction set to transaction, an undefined position, direction set to direction, got value flag unset, and undefined key and value. The source of cursor is store. The range of cursor is range.
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to iterate a cursor as operation, using the current Realm as targetRealm, and cursor.
- %query ~parameterは、`~cursor$の`範囲$Csとして利用する `~key$/`~key範囲$ をとり得る。 ~NULL または省略時には,`全範囲$が利用される。 ◎ The query parameter may be a key or an IDBKeyRange to use as the cursor’s range. If null or not given, an unbounded key range is used.
- `openKeyCursor(query, direction)@m
-
被呼出時には、~MUST_RUN: ◎ The openKeyCursor(query, direction) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query. Rethrow any exceptions.
- %演算 ~SET 次を入力に `~cursorを作成-$する`演算$ ⇒# %source ~SET 此れ, %方向 ~SET %direction, %範囲 ~SET %範囲, %~key~only~flag ~SET ~ON ◎ Let cursor be a new cursor with transaction set to transaction, an undefined position, direction set to direction, got value flag unset, and undefined key and value. The source of cursor is store. The range of cursor is range. The key only flag of cursor is set.
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this object store handle as source and the steps to iterate a cursor as operation, using the current Realm as targetRealm, and cursor.
- %query ~parameterは、`~cursor$の`範囲$Csとして利用する `~key$/`~key範囲$ をとり得る。 ~NULL または省略時には,`全範囲$が利用される。 ◎ The query parameter may be a key or an IDBKeyRange to use as the cursor’s range. If null or not given, an unbounded key range is used.
- %index = %store . `index$m(%name)
- [ %store↗ に`専属する$,`名前$Ix %name の`索引$ ]を`~access先$とする,`索引~handle$( `IDBIndex$I )を返す。 ◎ Returns an IDBIndex for the index named name in store.
- %index = %store . `createIndex$m(%name, %keyPath [, %options])
- %store↗ に`専属する$新たな`索引$を,所与の[ %name, %keyPath, %options ]を伴うように作成した上で、それを`~access先$とする新たな `IDBIndex$I を返す。 [ %keyPath, %options ]が %store 内にすでにある~dataから 索引を拡充- できない拘束を定義する場合、当の`昇格~tx$は `ConstraintError$E で`中止-$されることになる。 ◎ Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException.
- `昇格~txの外$で~callされた場合、 `InvalidStateError$E が投出される。 ◎ Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
- %store . `deleteIndex$m(%name)
- %store↗ に`専属する$,`名前$Ix %name の`索引$を削除する。 ◎ Deletes the index in store with the given name.
- `昇格~txの外$で~callされた場合、 `InvalidStateError$E が投出される。 ◎ Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
- `createIndex(name, keyPath, options)@m
-
被呼出時には、~MUST_RUN: ◎ The createIndex(name, keyPath, options) method, when invoked, must run these steps:
- `CheckState$( 此れ, `versionchange^l ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If transaction is not an upgrade transaction, throw an "InvalidStateError" DOMException. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- ~IF[ 此れの`索引~集合$OsHに[ `名前$Ix ~EQ %name ]なる`索引$がある ] ⇒ ~THROW `ConstraintError$E ◎ If an index named name already exists in store, throw a "ConstraintError" DOMException.
- ~IF[ %keyPath は`妥当な~key~path$でない ] ⇒ ~THROW `SyntaxError$E ◎ If keyPath is not a valid key path, throw a "SyntaxError" DOMException.
- `一意?^V ~LET %options の `unique^m ~memberの値 ◎ Let unique be set if options’s unique member is true, and unset otherwise.
- %multiEntry ~LET %options の `multiEntry^m ~memberの値 ◎ Let multiEntry be set if options’s multiEntry member is true, and unset otherwise.
- ~IF[ %keyPath は~SeqDS型である ]~AND[ %multiEntry ~EQ ~T ] ⇒ ~THROW `InvalidAccessError$E ◎ If keyPath is a sequence and multiEntry is set, throw an "InvalidAccessError" DOMException.
- %索引 ~LET 次の様にされた新たな`索引$† ⇒# 此れ↗に`専属する$, `名前$Ix ~SET %name, `~key~path$Ix ~SET %keyPath, `一意~flag$Ix ~SET `Flag$( `一意?^V ), `複entry~flag$Ix ~SET `Flag$( %multiEntry ) ◎ Let index be a new index in store. Set index’s name to name and key path to keyPath. If unique is set, set index’s unique flag. If multiEntry is set, set index’s multiEntry flag.
- %索引 を此れの`索引~集合$OsHに追加する ◎ Add index to this object store handle’s index set.
- ~RET 次のようにされた,新たな`索引~handle$ %H ⇒# %H↗ ~EQ %索引, %H は此れに`専属する$, `名前$IxH ~SET %name ◎ Return a new index handle associated with index and this object store handle.
【† 索引の`~record~list$Ixは、自動的に此れの`~record~list$Osにより拡充されることになる。 】
-
この~methodは、此れに`専属する$, 名前 %name の新たな`索引$を作成した上で、それを`~access先$とする 新たな`索引~handle$を返す。 この~methodを~callできるのは、`昇格~txの中$からに限られることに注意。 ◎ This method creates and returns a new index with the given name in the object store. Note that this method must only be called from within an upgrade transaction.
作成するよう要請された索引は、[ 自身が`専属する$`保管庫$に許容される~data ]についての拘束を伴うこともある — `一意~flag$Ixにより,索引の`~key~path$Ixが指す部位の値(`参照先~record$の値)の一意性が要求されるなど。 その保管庫が,この拘束に違反する~dataをすでに包含している場合でも、実装は,[ この~methodにて例外を投出したり,それが返すものに影響させる ]ことなく,依然として `IDBIndex^I ~objを作成して返さ~MUST。 代わりに実装は、[ この~methodの~callに利用された,`昇格~tx$ ]を中止する`~taskを~queueし$~MUST。 ◎ The index that is requested to be created can contain constraints on the data allowed in the index’s referenced object store, such as requiring uniqueness of the values referenced by the index’s keyPath. If the referenced object store already contains data which violates these constraints, this must not cause the implementation of createIndex() to throw an exception or affect what it returns. The implementation must still create and return an IDBIndex object, and the implementation must queue a task to abort the upgrade transaction which was used for the createIndex() call.
この~methodは、此れ上の `indexNames$m ~propを同期的に改変する。 この~methodは `IDBRequest$I ~objを返さないが、索引の作成~自体は,`昇格~tx$の中の非同期的な要請として,処理される。 ◎ This method synchronously modifies the indexNames property on the IDBObjectStore instance on which it was called. Although this method does not return an IDBRequest object, the index creation itself is processed as an asynchronous request within the upgrade transaction.
実装によっては、この~methodが`索引~handle$( `IDBIndex^I ~obj)を返した後,`索引$を非同期に作成するときに,問題になる可能性がある。 例えば、[ 新たに作成された索引の~metadataを~dbに挿入する~taskを~queueする所 ],あるいは[ ~quota事由から,利用者に許可を請う必要があり得る所 ]で。 そのような場合でも,実装は:
- 依然として、`索引~handle$を作成して返さ~MUST。
-
加えて,`索引$の作成ingに失敗したときは、次を入力に `~txを中止-$して,その~txを`中止-$し~MUST ⇒ %error ~SET 失敗の事由に適切な~error名
例えば、[ ~quota事由に因り`索引$の作成ingに失敗した場合は `QuotaExceededError$E / `一意~flag$Ixの拘束に因り索引を作成できない場合は `ConstraintError$E ]を利用し~MUST。
- `index(name)@m
-
被呼出時には、~MUST_RUN: ◎ The index(name) method, when invoked, must run these steps:
- ~IF[ 此れ↗は削除されている ] ⇒ ~THROW `InvalidStateError$E ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If store has been deleted, throw an "InvalidStateError" DOMException.
- ~IF 此れが`専属する$`~tx$は すでに`終了-$した ⇒ ~THROW `InvalidStateError$E ◎ If transaction has finished, throw an "InvalidStateError" DOMException.
- %索引 ~LET 此れの`索引~集合$OsH 内の`索引$のうち,[ `名前$Ix ~EQ %name ]なるもの
- ~IF[ %索引 ~EQ ε ] ⇒ ~THROW `NotFoundError$E ◎ Let index be the index named name in this object store handle’s index set if one exists, or throw a "NotFoundError" DOMException otherwise.
- ~RET 次を満たすような`索引~handle$ %H ⇒# %H↗ ~EQ %索引, %H は此れに`専属する$, `一意性$の要件を満たす(`可換性$の要件は、`索引~集合$OsHの構成から自動的に満たされる) ◎ Return an index handle associated with index and this object store handle.
- 注記: `一意性$の要件から,返される~instanceは一意に定まる 【~instanceがその前のどの時点で作成されるかは,実装の詳細になる】 。 よって、`昇格~tx$の間を除き、同じ `IDBObjectStore$I ~instance上で,同じ %name をこの~methodに渡して返される `IDBIndex$I ~instanceは、常に同じになる。 ◎ Each call to this method on the same IDBObjectStore instance with the same name returns the same IDBIndex instance.
- 注記: %H は此れに`専属する$ので、他の `IDBObjectStore$I ~instanceに対し同じ %name で この~methodを呼出しても, %H と異なる `IDBIndex$I ~instanceが返される。 ◎ The returned IDBIndex instance is specific to this IDBObjectStore instance. If this method is called on a different IDBObjectStore instance with the same name, a different IDBIndex instance is returned.
- `deleteIndex(name)@m
-
被呼出時には、~MUST_RUN: ◎ The deleteIndex(name) method, when invoked, must run these steps:
- `CheckState$( 此れ, `versionchange^l ) ? ◎ Let transaction be this object store handle’s transaction. ◎ Let store be this object store handle’s object store. ◎ If transaction is not an upgrade transaction, throw an "InvalidStateError" DOMException. ◎ If store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %索引 ~LET 此れ↗に`専属する$`索引$のうち,[ `名前$Ix ~EQ %name ]なるもの ◎ Let index be the index named name in store if one exists,\
- ~IF[ %索引 ~EQ ε ] ⇒ ~THROW `NotFoundError$E ◎ or throw a "NotFoundError" DOMException otherwise.
- 此れの`索引~集合$OsHから %索引 を除去する ◎ Remove index from this object store handle’s index set.
- %索引 を破壊する ◎ Destroy index.
この~methodは、此れ↗に専属する,名前 %name の`索引$を破壊する。 この~methodを~callできるのは、`昇格~txの中$からに限られることに注意。 ◎ This method destroys the index with the given name in the object store. Note that this method must only be called from within an upgrade transaction.
この~methodは、此れ上の `indexNames$m 属性を同期的に改変する。 この~methodは `IDBRequest$I ~objを返さないが、索引の破壊~自体は,`昇格~tx$の中で非同期的な要請として処理される。 ◎ This method synchronously modifies the indexNames property on the IDBObjectStore instance on which it was called. Although this method does not return an IDBRequest object, the index destruction itself is processed as an asynchronous request within the upgrade transaction.
4.6. `IDBIndex^I ~interface
`IDBIndex$I ~interfaceは、`索引~handle$を表現する。 ◎ The IDBIndex interface represents an index handle.
[`Exposed$=(Window,Worker)] interface `IDBIndex@I { attribute DOMString `name$m; [`SameObject$] readonly attribute `IDBObjectStore$I `objectStore$m; readonly attribute any `keyPath$m; readonly attribute boolean `multiEntry$m; readonly attribute boolean `unique$m; [`NewObject$] `IDBRequest$I `get$m( any %query ); [`NewObject$] `IDBRequest$I `getKey$m( any %query ); [`NewObject$] `IDBRequest$I `getAll$m( optional any %query, optional [`EnforceRange$] unsigned long %count ); [`NewObject$] `IDBRequest$I `getAllKeys$m( optional any %query, optional [`EnforceRange$] unsigned long %count ); [`NewObject$] `IDBRequest$I `count$m( optional any %query ); [`NewObject$] `IDBRequest$I `openCursor$m( optional any %query, optional `IDBCursorDirection$I %direction = "next" ); [`NewObject$] `IDBRequest$I `openKeyCursor$m( optional any %query, optional `IDBCursorDirection$I %direction = "next" ); };
- %index . `name$m
- %index↗ の`名前$Ixを返す。 ◎ Returns the name of the index.
- %index . `name$m = %newName
- %index↗ の`名前$Ixを %newName に更新する。 ◎ Updates the name of the store to newName.
- `昇格~txの外$で~callされた場合、 `InvalidStateError$E が投出される。 ◎ Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
- %index . `objectStore$m
- %index が`専属する$`保管庫~handle$( `IDBObjectStore$I )を返す。 ◎ Returns the IDBObjectStore the index belongs to.
- %index . `keyPath$m
- %index↗ の`~key~path$Ixを返す。 ◎ Returns the key path of the index.
- %index . `multiEntry$m
- %index↗ の`複entry~flag$Ixに応じて,[ ~ON ならば ~T / ~OFF ならば ~F ]を返す。 ◎ Returns true if the index’s multiEntry flag is set.
- %index . `unique$m
- %index↗ の`一意~flag$Ixに応じて,[ ~ON ならば ~T / ~OFF ならば ~F ]を返す。 ◎ Returns true if the index’s unique flag is set.
- `name@m
- 取得子は、此れの`名前$IxHを返さ~MUST。 ◎ The name attribute’s getter must return this index handle’s name.
- 注記: 此れが`専属する$~txが`終了-$されない限り、返される値は此れ↗の`名前$Ixと同じになり、それ以降も同じ`値を保持し続ける$。 ◎ Is this the same as the index's name? ◎ As long as the transaction has not finished, this is the same as the associated index’s name. But once the transaction has finished, this attribute will not reflect changes made with a later upgrade transaction.
-
設定子は、~MUST_RUN: ◎ The name attribute’s setter must run these steps:
- `CheckState$( 此れ, `versionchange^l ) ? ◎ Let name be the given value. ◎ Let transaction be this index handle’s transaction. ◎ Let index be this index handle’s index. ◎ If transaction is not an upgrade transaction, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException. ◎ 変則* If index or index’s object store has been deleted, throw an "InvalidStateError" DOMException.
- %name ~LET 与えられた値 ◎ ↑
- ~IF[ 此れの`名前$IxH ~EQ %name ] ⇒ ~RET ◎ If index’s name is equal to name, terminate these steps.
- ~IF[[ 此れが`専属する$`保管庫~handle$ ]の`索引~集合$OsHに[ `名前$IxH ~EQ %name ]なる`索引$がある ] ⇒ ~THROW `ConstraintError$E ◎ If an index named name already exists in index’s object store, throw a "ConstraintError" DOMException.
- 此れ↗の`名前$Ix ~SET %name ◎ Set index’s name to name.
- 此れの`名前$IxH ~SET %name ◎ Set this index handle’s name to name.
- `objectStore@m
- 取得子は、此れが`専属する$`保管庫~handle$を返さ~MUST。 ◎ The objectStore attribute’s getter must return this index handle’s object store handle.
- `keyPath@m
- 取得子は、此れ↗の`~key~path$Ix %P に応じて,[ %P ~EQ ε ならば ~NULL / ~ELSE_ `WEBIDL$r に従って %P を[ %P は文字列ならば ~DS型 / %P は文字列の~listならば ~SeqDS型 ]に変換した結果 ]を返さ~MUST。 この属性は、`値を保持し続ける$。 ◎ The keyPath attribute’s getter must return this index handle's index's key path. The key path is converted as a DOMString (if a string) or a sequence<DOMString> (if a list of strings), per [WEBIDL].
- 返される値は、此れの作成-時に利用した~instanceと同じではない。 しかしながら,この属性が~obj(すなわち, `Array$js )を返す場合、毎回~同じ~instanceを返す。 返された~objの~prop値を変更しても,此れに効果を及ぼすことはない。 ◎ The returned value is not the same instance that was used when the index was created. However, if this attribute returns an object (specifically an Array), it returns the same object instance every time it is inspected. Changing the properties of the object has no effect on the index.
- `multiEntry@m
- 取得子は、 `Bool$( 此れ↗の`複entry~flag$Ix ) を返さ~MUST。 この属性は、`値を保持し続ける$。 ◎ The multiEntry attribute’s getter must return true if this index handle’s index’s multiEntry flag is set, and false otherwise.
- `unique@m
- 取得子は、 `Bool$( 此れ↗の`一意~flag$Ix ) を返さ~MUST。 この属性は、`値を保持し続ける$。 ◎ The unique attribute’s getter must return true if this index handle’s index’s unique flag is set, and false otherwise.
以下に挙げる~methodは、`~tx$が`作動中$でないときに~callされた場合は `TransactionInactiveError$E を投出する。 ◎ The following methods throw an "TransactionInactiveError" DOMException if called when the transaction is not active.
- %request = %index . `get$m(%query)
- %index↗ の`~record~list$Ix内の[ %query が`表現する~key範囲$に入る~recordたち ]のうち,最初の~recordの`参照先~record$の`値$を検索取得するよう要請する。 ◎ Retrieves the value of the first record matching the given key or key range in query.
- 成功した場合の %request の `result$m は、該当する~recordが[ あれば 得られた値/ なければ `undefined^js ]になる。 ◎ If successful, request’s result will be the value, or undefined if there was no matching record.
- %request = %index . `getKey$m(%query)
- %index↗ の`~record~list$Ix内の[ %query が`表現する~key範囲$に入る~recordたち ]のうち,最初の~recordの値 — すなわち,`参照先~record$の`~key$ — を検索取得するよう要請する。 ◎ Retrieves the key of the first record matching the given key or key range in query.
- 成功した場合の %request の `result$m は、該当する~recordが[ あれば 得られた`~key$ / なければ `undefined^js ]になる。 ◎ If successful, request’s result will be the key, or undefined if there was no matching record.
- %request = %index . `getAll$m(%query [, %count])
- %index↗ の`~record~list$Ix内の[ %query が`表現する~key範囲$に入る~recordたち ]のうち,最初から %count 個までの~recordの`参照先~record$の値たちを検索取得するよう要請する。 ◎ Retrieves the values of the records matching the given key or key range in query (up to count if given).
- 成功した場合の %request の `result$m は、一連の`値$からなる `Array$js になる。 ◎ If successful, request’s result will be an Array of the values.
- %request = %index . `getAllKeys$m(%query [, %count])
- %index↗ の`~record~list$Ix内の[ %query が`表現する~key範囲$に入る~recordたち ]のうち,最初から %count 個までの~recordの値 — すなわち,`参照先~record$の`~key$ — たちを検索取得するよう要請する。 ◎ Retrieves the keys of records matching the given key or key range in query (up to count if given).
- 成功した場合の %request の `result$m は、一連の`~key$からなる `Array$js になる。 ◎ If successful, request’s result will be an Array of the keys.
- %request = %index . `count$m(%query)
- %index↗ の`~record~list$Ix内の[ %query が`表現する~key範囲$に入る~recordたち ]の総数を得るよう要請する。 ◎ Retrieves the number of records matching the given key or key range in query.
- 成功した場合の %request の `result$m は、得られた総数になる。 ◎ If successful, request’s result will be the count.
- `get(query)@m
-
被呼出時には、~MUST_RUN: ◎ The get(query) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this index handle’s transaction. ◎ Let index be this index handle’s index. ◎ If index or index’s object store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query, `~NULL不可^i ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query and null disallowed flag set. Rethrow any exceptions.
- %演算 ~SET 次を入力に `範囲に入る最初の~entryを検索取得する$`演算$ ⇒# %対象 ~SET 此れ↗, %範囲 ~SET %範囲, %取得演算 ~SET [ %record → ! `StructuredDeserialize$jA( %record の`参照先~record$の値, `現在の~Realm$ ) ] ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this index handle as source and the steps to retrieve a referenced value from an index as operation, using the current Realm as targetRealm, index and range.
- %query ~parameterは、検索取得する`~record$を識別する `~key$/`~key範囲$ をとり得る。 範囲が指定された場合、~methodは,その範囲に入る最初の既存の~recordの値を検索取得する。 ◎ The query parameter may be a key or an IDBKeyRange identifying the record to be retrieved. If a range is specified, the method retrieves the first existing record in that range.
- 注記: `IDBObjectStore.get()$m の注記にて述べたことが,この~methodにも該当する。 ◎ This method produces the same result if a record with the given key doesn’t exist as when a record exists, but has undefined as value. If you need to tell the two situations apart, you can use openCursor() with the same key. This will return a cursor with undefined as value if a record exists, or no cursor if no such record exists.
- `getKey(query)@m
-
被呼出時には、~MUST_RUN: ◎ The getKey(query) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this index handle’s transaction. ◎ Let index be this index handle’s index. ◎ If index or index’s object store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query, `~NULL不可^i ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query and null disallowed flag set. Rethrow any exceptions.
- %演算 ~SET 次を入力に `範囲に入る最初の~entryを検索取得する$`演算$ ⇒# %対象 ~SET 此れ↗, %範囲 ~SET %範囲, %取得演算 ~SET [ %record → `Value1$( %record の`値$ ) ] ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this index handle as source and the steps to retrieve a value from an index as operation, using index and range.
- %query ~parameterは、検索取得する`~record$の~keyを識別する `~key$/`~key範囲$ をとり得る。 範囲が指定された場合、~methodは,その範囲に入る最初の既存の~keyを検索取得する。 ◎ The query parameter may be a key or an IDBKeyRange identifying the record key to be retrieved. If a range is specified, the method retrieves the first existing key in that range.
- `getAll(query, count)@m
-
被呼出時には、~MUST_RUN: ◎ The getAll(query, count) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this index handle’s transaction. ◎ Let index be this index handle’s index. ◎ If index or index’s object store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query. Rethrow any exceptions.
- %演算 ~SET 次を入力に `範囲に入る~entryたちを検索取得する$`演算$ ⇒# %対象 ~SET 此れ↗, %範囲 ~SET %範囲, %取得演算 ~SET [ %record → ! `StructuredDeserialize$jA( %record の`参照先~record$の値, `現在の~Realm$ ) ], %count ~SET %count ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this index handle as source and the steps to retrieve multiple referenced values from an index as operation, using the current Realm as targetRealm, index, range, and count if given.
- %query ~parameterは、検索取得する`~record$たちを識別する `~key$/`~key範囲$ をとり得る。 ~NULL または省略時には,`全範囲$が利用される。 %count が指定されていて,範囲に入る~record数がそれを超える場合,最初から %count 個までが検索取得される。 ◎ The query parameter may be a key or an IDBKeyRange identifying the records to be retrieved. If null or not given, an unbounded key range is used. If count is specified and there are more than count records in range, only the first count will be retrieved.
- `getAllKeys(query, count)@m
-
被呼出時には、~MUST_RUN: ◎ The getAllKeys(query, count) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this index handle’s transaction. ◎ Let index be this index handle’s index. ◎ If index or index’s object store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query. Rethrow any exceptions.
- %演算 ~SET 次を入力に `範囲に入る~entryたちを検索取得する$`演算$ ⇒# %対象 ~SET 此れ↗, %範囲 ~SET %範囲, %取得演算 ~SET [ %record → `Value1$( %record の`値$ ) ], %count ~SET %count ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this index handle as source and the steps to retrieve multiple values from an index as operation, using index, range, and count if given.
- %query ~parameterは、検索取得する`~record$たちの~keyを識別する `~key$/`~key範囲$ をとり得る。 ~NULL または省略時には,`全範囲$が利用される。 %count が指定されていて,範囲に入る~key数がそれを超える場合,最初から %count 個までが検索取得される。 ◎ The query parameter may be a key or an IDBKeyRange identifying the records keys to be retrieved. If null or not given, an unbounded key range is used. If count is specified and there are more than count keys in range, only the first count will be retrieved.
- `count(query)@m
-
被呼出時には、~MUST_RUN: ◎ The count(query) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this index handle’s transaction. ◎ Let index be this index handle’s index. ◎ If index or index’s object store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query. Rethrow any exceptions.
- %演算 ~SET 次を入力に `範囲に入る~recordを数える$`演算$ ⇒# %source ~SET 此れ↗, %範囲 ~SET %範囲 ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this index handle as source and the steps to count the records in a range as operation, with index as source and range.
- %query ~parameterは、数えられる`~record$たちの~keyを識別する `~key$/`~key範囲$ をとり得る。 ~NULL または省略時には,`全範囲$が利用される。 ◎ The query parameter may be a key or an IDBKeyRange identifying the records keys to be counted. If null or not given, an unbounded key range is used.
以下に挙げる~methodは、`~tx$が`作動中$でないときに~callされた場合は `TransactionInactiveError$E を投出する。 ◎ The following methods throw an "TransactionInactiveError" DOMException if called when the transaction is not active.
- %request = %index . `openCursor$m([%query [, %direction = "next"]])
- [ %index↗ の`~record~list$Os内の[ %query が`表現する~key範囲$( %query が~NULL ならば`全範囲$)に入る~recordたち ]を,`方向$Cs %direction で反復する`~cursor$ ]を作成するよう要請する。 ◎ Opens a cursor over the records matching query, ordered by direction. If query is null, all records in index are matched.
- 成功した場合の %request の `result$m は、範囲に入る~recordが[ なければ ~NULL / あれば 反復-順で最初の~recordを指している `IDBCursorWithValue$I ]になる。 ◎ If successful, request’s result will be an IDBCursorWithValue, or null if there were no matching records.
- %request = %index . `openKeyCursor$m([%query [, %direction = "next"]])
- [ %index↗ の`~record~list$Ix内の[ %query が`表現する~key範囲$( %query が~NULL ならば`全範囲$)に入る~recordたち ]を,`方向$Cs %direction で反復する`~cursor$ ]を作成するよう要請する。 作成される`~cursor$の`~key~only~flag$Csは ~ON になる(~cursorは、~recordの~keyのみを取得する)。 ◎ Opens a cursor with key only flag set over the records matching query, ordered by direction. If query is null, all records in index are matched.
- 成功した場合の %request の `result$m は、範囲に入る~recordが[ なければ ~NULL / あれば 反復-順で最初の~recordを指している `IDBCursor$I ]になる。 ◎ If successful, request’s result will be an IDBCursor, or null if there were no matching records.
- `openCursor(query, direction)@m
-
被呼出時には、~MUST_RUN: ◎ The openCursor(query, direction) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this index handle’s transaction. ◎ Let index be this index handle’s index. ◎ If index or index’s object store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query. Rethrow any exceptions.
- %演算 ~SET 次を入力に `~cursorを作成-$する`演算$ ⇒# %source ~SET 此れ, %方向 ~SET %direction, %範囲 ~SET %範囲, %~key~only~flag ~SET ~OFF ◎ ↓
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Let cursor be a new cursor with transaction set to transaction, an undefined position, direction set to direction, got value flag unset, and undefined key and value. The source of cursor is index. The range of cursor is range. ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this index handle as source and the steps to iterate a cursor as operation, using the current Realm as targetRealm, and cursor.
- %query ~parameterは、`~cursor$の`範囲$Csとして利用する `~key$/`~key範囲$ をとり得る。 ~NULL または省略時には,`全範囲$が利用される。 ◎ The query parameter may be a key or an IDBKeyRange to use as the cursor’s range. If null or not given, an unbounded key range is used.
- `openKeyCursor(query, direction)@m
-
被呼出時には、~MUST_RUN: ◎ The openKeyCursor(query, direction) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this index handle’s transaction. ◎ Let index be this index handle’s index. ◎ If index or index’s object store has been deleted, throw an "InvalidStateError" DOMException. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- %範囲 ~LET `Range$( %query ) ? ◎ Let range be the result of running the steps to convert a value to a key range with query. Rethrow any exceptions.
- %演算 ~SET 次を入力に `~cursorを作成-$する`演算$ ⇒# %source ~SET 此れ, %方向 ~SET %direction, %範囲 ~SET %範囲, %~key~only~flag ~SET ~ON ◎ Let cursor be a new cursor with transaction set to transaction, an undefined position, direction set to direction, got value flag unset, and undefined key and value. The source of cursor is index. The range of cursor is range. The key only flag of cursor is set.
- ~RET 此れ上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this index handle as source and the steps to iterate a cursor as operation, using the current Realm as targetRealm, and cursor.
- %query ~parameterは、`~cursor$の`範囲$Csとして利用する `~key$/`~key範囲$ をとり得る。 ~NULL または省略時には,`全範囲$が利用される。 ◎ The query parameter may be a key or an IDBKeyRange to use as the cursor’s range. If null or not given, an unbounded key range is used.
4.7. `IDBKeyRange^I ~interface
`IDBKeyRange$I ~interfaceは、`~key範囲$を表現する。 ◎ The IDBKeyRange interface represents a key range.
[`Exposed$=(Window,Worker)]
interface `IDBKeyRange@I {
readonly attribute any `lower$m;
readonly attribute any `upper$m;
readonly attribute boolean `lowerOpen$m;
readonly attribute boolean `upperOpen$m;
// 静的~構築~method:
[`NewObject$] static `IDBKeyRange$I `only$m(
any %value
);
[`NewObject$] static `IDBKeyRange$I `lowerBound$m(
any %lower,
optional boolean %open = false
);
[`NewObject$] static `IDBKeyRange$I `upperBound$m(
any %upper,
optional boolean %open = false
);
[`NewObject$] static `IDBKeyRange$I `bound$m(
any %lower,
any %upper,
optional boolean %lowerOpen = false,
optional boolean %upperOpen = false
);
boolean _`includes$m(any %key);
};
- %range . `lower$m
- `下界$が[ あれば それ / なければ `undefined^js ]を返す。 ◎ Returns lower bound, or undefined if none.
- %range . `upper$m
- `上界$が[ あれば それ / なければ `undefined^js ]を返す。 ◎ Returns upper bound, or undefined if none.
- %range . `lowerOpen$m
- `下界open~flag$に応じて,[ ~ON ならば ~T / ~OFF ならば ~F ]を返す。 ◎ Returns true if the lower open flag is set, and false otherwise.
- %range . `upperOpen$m
- `上界open~flag$に応じて,[ ~ON ならば ~T / ~OFF ならば ~F ]を返す。 ◎ Returns true if the upper open flag is set, and false otherwise.
- `lower@m
- 取得子は、 `Value$( 此れの`下界$ ) を返さ~MUST。 ◎ The lower attribute’s getter must return result of running the steps to convert a key to a value with the lower bound if it is not null, or undefined otherwise.
- `upper@m
- 取得子は、 `Value$( 此れの`上界$ ) を返さ~MUST。 ◎ The upper attribute’s getter must return the result of running the steps to convert a key to a value with the upper bound if it is not null, or undefined otherwise.
- `lowerOpen@m
- 取得子は、 `Bool$( 此れの`下界open~flag$ ) を返さ~MUST。 ◎ The lowerOpen attribute’s getter must return true if the lower open flag is set, and false otherwise.
- `upperOpen@m
- 取得子は、 `Bool$( 此れの`上界open~flag$ ) を返さ~MUST。 ◎ The upperOpen attribute’s getter must return true if the upper open flag is set, and false otherwise.
- %range = `IDBKeyRange$I . `only$m(%key)
- %value のみを含む,新たな `IDBKeyRange$I ( `~key範囲$ )を返す。 ◎ Returns a new IDBKeyRange spanning only key.
- %range = `IDBKeyRange$I . `lowerBound$m(%lower [, %open = false])
- `下界$ %lower から開始され, `上界$のない,新たな `IDBKeyRange$I を返す。 %open が ~T の場合、 %lower はこの範囲に含まれない。 ◎ Returns a new IDBKeyRange starting at key with no upper bound. If open is true, key is not included in the range.
- %range = `IDBKeyRange$I . `upperBound$m(%upper [, %open = false])
- `下界$のない, `上界$ %upper で終端する,新たな `IDBKeyRange$I を返す。 %open が ~T の場合、 %upper はこの範囲に含まれない。 ◎ Returns a new IDBKeyRange with no lower bound and ending at key. If open is true, key is not included in the range.
- %range = `IDBKeyRange$I . `bound$m(%lower, %upper [, %lowerOpen = false [, %upperOpen = false]])
- `下界$ %lower から `上界$ %upper までにわたる,新たな `IDBKeyRange$I を返す。 %lowerOpen が ~T の場合、 %lower はこの範囲に含まれない。 %upperOpen が ~T の場合、 %upper はこの範囲に含まれない。 ◎ Returns a new IDBKeyRange spanning from lower to upper. If lowerOpen is true, lower is not included in the range. If upperOpen is true, upper is not included in the range.
- 【
%lower / %upper
に対する `undefined^js は、許容されない(省略可能でないので)。
したがって,[
`下界$ /`上界$
]のない`~key範囲$を作成するためには、他の~methodを利用する必要がある。
`全範囲$を表現する `IDBKeyRange^I ~objは 作成できないが、
`lowerBound$m(`-Infinity^js)
により,実質的に等価なものは作成できる。 また、他の各種~API~methodの引数のうち,`~key範囲$を期待するもの(この仕様の~IDLで %query と記される引数)は、(省略可能であれば)省略した場合には`全範囲$に解釈される。 】
- `only(value)@m
-
被呼出時には、~MUST_RUN: ◎ The only(value) method, when invoked, must run these steps:
- ~RET `Only$( `Key$( %value ) ) ? ◎ Let key be the result of running the steps to convert a value to a key with value. Rethrow any exceptions. ◎ If key is invalid, throw a "DataError" DOMException. ◎ Create and return a new key range containing only key.
- `lowerBound(lower, open)@m
-
被呼出時には、~MUST_RUN: ◎ The lowerBound(lower, lowerOpen) method, when invoked, must run these steps:
- %lowerKey ~LET `Key$( %lower ) ? ◎ Let lowerKey be the result of running the steps to convert a value to a key with lower. Rethrow any exceptions. ◎ If lowerKey is invalid, throw a "DataError" DOMException.
- ~RET 次の様にされた,新たな`~key範囲$ ⇒# `下界$ ~SET %lowerKey, `下界open~flag$ ~SET `Flag$( %open ), `上界$ ~SET ε, `上界open~flag$ ~SET ~ON ◎ Create and return a new key range with lower bound set to lowerKey, lower open flag set if lowerOpen is true, upper bound set to null and upper open flag set.
- `upperBound(upper, open)@m
-
被呼出時には、~MUST_RUN: ◎ The upperBound(upper, upperOpen) method, when invoked, must run these steps:
- %upperKey ~LET `Key$( %upper ) ? ◎ Let upperKey be the result of running the steps to convert a value to a key with upper. Rethrow any exceptions. ◎ If upperKey is invalid, throw a "DataError" DOMException.
- ~RET 次の様にされた,新たな`~key範囲$ ⇒# `下界$ ~SET ε, `下界open~flag$ ~SET ~ON, `上界$ ~SET %upperKey, `上界open~flag$ ~SET `Flag$( %open ) ◎ Create and return a new key range with lower bound set to null, lower open flag set, upper bound set if upperKey, and upper open flag set to upperOpen.
- `bound(lower, upper, lowerOpen, upperOpen)@m
-
被呼出時には、~MUST_RUN: ◎ The bound(lower, upper, lowerOpen, upperOpen) method, when invoked, must run these steps:
- %lowerKey ~LET `Key$( %lower ) ? ◎ Let lowerKey be the result of running the steps to convert a value to a key with lower. Rethrow any exceptions. ◎ If lowerKey is invalid, throw a "DataError" DOMException.
- %upperKey ~LET `Key$( %upper ) ? ◎ Let upperKey be the result of running the steps to convert a value to a key with upper. Rethrow any exceptions. ◎ If upperKey is invalid, throw a "DataError" DOMException.
- ~IF[ %lower ~GT~cmpkey %upper ] ⇒ ~THROW `DataError$E ◎ If lowerKey is greater than upperKey, throw a "DataError" DOMException.
- ~RET 次の様にされた,新たな`~key範囲$ ⇒# `下界$ ~SET %lowerKey, `下界open~flag$ ~SET `Flag$( %lowerOpen ), `上界$ ~SET %upperKey, `上界open~flag$ ~SET `Flag$( %upperOpen ) ◎ Create and return a new key range with lower bound set to lowerKey, lower open flag set if lowerOpen is true, upper bound set to upperKey and upper open flag set if upperOpen is true.
- %range . `includes$m(%key)
- [ %key が %range に`入る$ならば ~T / ~ELSE_ ~F ]を返す。 ◎ Returns true if key is included in the range, and false otherwise.
- `includes(key)@m
-
被呼出時には、~MUST_RUN: ◎ The includes(key) method, when invoked, must run these steps:
- %key ~LET `Key$( %key ) ? ◎ Let k be the result of running the steps to convert a value to a key with key. Rethrow any exceptions. ◎ If k is invalid, throw a "DataError" DOMException.
- ~IF [ %key ~IN~cmpkey 此れ ] ⇒ ~RET ~T ◎ Return true if k is in this range, and\
- ~RET ~F ◎ false otherwise.
4.8. `IDBCursor^I ~interface
`~cursor$~objは、 `IDBCursor$I ~interfaceを実装する。 所与の`~cursor$を表現するような `IDBCursor$I ~instanceは,唯一つに限られるが、同時に利用できる~cursorの~~総数に上限はない。 ◎ Cursor objects implement the IDBCursor interface. There is only ever one IDBCursor instance representing a given cursor. There is no limit on how many cursors can be used at the same time.
[`Exposed$=(Window,Worker)] interface `IDBCursor@I { readonly attribute (`IDBObjectStore$I or `IDBIndex$I) `source$m; readonly attribute `IDBCursorDirection$I `direction$m; readonly attribute any `key$m; readonly attribute any `primaryKey$m; void `advance$m( [`EnforceRange$] unsigned long %count ); void `continue$m( optional any %key ); void `continuePrimaryKey$m( any %key, any %primaryKey ); [`NewObject$] `IDBRequest$I `update$m( any %value ); [`NewObject$] `IDBRequest$I `delete$m(); }; enum `IDBCursorDirection@I { `next$l, `nextunique$l, `prev$l, `prevunique$l };
- %cursor . `source$m
- %cursor の`~source$Cs( `IDBObjectStore$I / `IDBIndex$I )を返す。 ◎ Returns the IDBObjectStore or IDBIndex the cursor was opened from.
- %range . `direction$m
- %cursor の`方向$Cs( `next$l / `nextunique$l / `prev$l / `prevunique$l )を返す。 ◎ Returns the direction ("next", "nextunique", "prev" or "prevunique") of the cursor.
- %cursor . `key$m
- %cursor の`~key$Csを返す。 %cursor を進めている間 / 反復し終えていた場合、 `InvalidStateError$E が投出される†。 ◎ Returns the key of the cursor. Throws a "InvalidStateError" DOMException if the cursor is advancing or is finished.
- %cursor . `primaryKey$m
- %cursor の`実効~key$Csを返す。 %cursor を進めている間 / 反復し終えていた場合、 `InvalidStateError$E が投出される†。 ◎ Returns the effective key of the cursor. Throws a "InvalidStateError" DOMException if the cursor is advancing or is finished.
- 【† これらの要件は、下の規範的なテキストには述べられていない(何かの間違い?)。 】
- `source@m
- 取得子は、此れの`~source$Cs( %S とする)を返さ~MUST。 %S は、[ `~cursorを作成-$する手続きにて,此れを作成するよう要請した[ `保管庫~handle$/`索引~handle$ ]]に初期化され、それ以降は変化しない( %S が`専属する$~txが`作動中$でなくなっても, %S↗ が破壊されても)。 ◎ The source attribute’s getter must return the source of this cursor. This attribute never returns null or throws an exception, even if the cursor is currently being iterated, has iterated past its end, or its transaction is not active.
- `direction@m
- 取得子は、此れの`方向$Csを返さ~MUST。 ◎ The direction attribute’s getter must return the direction of the cursor.
- `key@m
-
取得子は、 `Value$( 此れの`~key$Cs ) を返さ~MUST。
この属性から~obj( `Date$js や `Array$js など)が返される場合、此れの`~key$Cs が変更されるまで,毎回~同じ~instanceを返すことになる。 すなわち、~objに加えられる改変は,どこからも見えることになる — しかしながら、その改変が~dbの内容を改変することはない。
◎ The key attribute’s getter must return the result of running the steps to convert a key to a value with the cursor’s current key. Note that if this property returns an object (e.g. a Date or Array), it returns the same object instance every time it is inspected, until the cursor’s key is changed. This means that if the object is modified, those modifications will be seen by anyone inspecting the value of the cursor. However modifying such an object does not modify the contents of the database. - `primaryKey@m
- 取得子は、 `Value$( 此れの`実効~key$Cs ) を返さ~MUST。 この属性にも `key^m 属性にて述べたこと が該当する。 ◎ The primaryKey attribute’s getter must return the result of running the steps to convert a key to a value with the cursor’s current effective key. Note that if this property returns an object (e.g. a Date or Array), it returns the same object instance every time it is inspected, until the cursor’s effective key is changed. This means that if the object is modified, those modifications will be seen by anyone inspecting the value of the cursor. However modifying such an object does not modify the contents of the database.
以下に挙げる~methodは、`~cursor$を その`範囲$Csに入る次の`~record$以降へ進めるよう要請する:
- 進め終えた時点で、~cursorの`要請$Csに向けて `success$et ~eventが発火されることになる。 `result$m は、[ `範囲$Csに入る`~record$があれば ~cursor自身 / ~ELSE_ `undefined^js ]になる。 ◎ The following methods advance a cursor. Once the cursor has advanced, a success event will be fired at the same IDBRequest returned when the cursor was opened. The result will be the same cursor if a record was in range, or undefined otherwise.
- ~cursorを進める前回の要請が(もしあって)完了する前に~callされた場合、 `InvalidStateError$E を投出する。 ◎ If called while the cursor is already advancing, an "InvalidStateError" DOMException will be thrown.
- `~tx$が`作動中$でないときに~callされた場合、 `TransactionInactiveError$E を投出する。 ◎ The following methods throw a "TransactionInactiveError" DOMException if called when the transaction is not active.
- %cursor . `advance$m(%count)
- %cursor を %count 個だけ先の~recordへ進める。 ◎ Advances the cursor through the next count records in range.
- %cursor . `continue$m()
- %cursor を次の~recordへ進める。 ◎ Advances the cursor to the next record in range.
- %cursor . `continue$m(%key)
- %cursor を,次の~record以降にある, かつ ~keyが %key 以降になるような,最初の~recordへ進める。 ◎ Advances the cursor to the next record in range matching or after key.
- %cursor . `continuePrimaryKey$m(%key, %primaryKey)
- %cursor を,次の~record以降にある, かつ ( ~key, 値 ) が ( %key, %primaryKey ) 以降になるような,最初の~recordへ進める。 %cursor の`~source$↗が`索引$でない場合、 `InvalidAccessError$E が投出される。 ◎ Advances the cursor to the next record in range matching or after key and primaryKey. Throws an "InvalidAccessError" DOMException if the source is not an index.
- `advance(count)@m
-
被呼出時には、~MUST_RUN: ◎ The advance(count) method, when invoked, must run these steps:
- ~IF[ %count ~EQ 0 ] ⇒ ~THROW `TypeError$js ◎ If count is 0 (zero), throw a TypeError.
- `CheckState$( 此れ ) ? ◎ Let transaction be this cursor’s transaction. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException. ◎ If the cursor’s source or effective object store has been deleted, throw an "InvalidStateError" DOMException.
- ~IF[ 此れの`値取得済~flag$Cs ~EQ ~OFF ] ⇒ ~THROW `InvalidStateError$E ◎ If this cursor’s got value flag is unset, indicating that the cursor is being iterated or has iterated past its end, throw an "InvalidStateError" DOMException.
- 此れの`値取得済~flag$Cs ~SET ~OFF ◎ Unset the got value flag on the cursor.
- %要請 ~SET 此れの`要請$Cs ◎ Let request be the request created when this cursor was created.
- %要請 の`~done~flag$ ~SET ~OFF ◎ Unset the done flag on request.
- %演算 ~SET 次を入力に `~cursorを反復-$する`演算$ ⇒# %cursor ~SET 此れ, %宛先~Realm ~SET `現在の~Realm$, %count ~SET %count ◎ ↓
- %要請 を用いて,此れの`~source$Cs上で %演算 を`非同期に実行する$ ◎ Run the steps to asynchronously execute a request with the cursor’s source as source, the steps to iterate a cursor as operation and request, using the current Realm as targetRealm, this cursor and count.
注記: 新たな~cursor~dataが読込まれる前に,この~methodを重ねて~callした場合 — 例えば,同じ `onsuccess^m ~handlerの~callの中で二度~callした場合 — 2 回目の~call時には、~cursorの`値取得済~flag$Csは ~OFF なので, `InvalidStateError$E 例外が投出されることになる。 ◎ Calling this method more than once before new cursor data has been loaded - for example, calling advance() twice from the same onsuccess handler - results in an "InvalidStateError" DOMException being thrown on the second call because the cursor’s got value flag has been unset.
- `continue(key)@m
-
被呼出時には、~MUST_RUN: ◎ The continue(key) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this cursor’s transaction. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException. ◎ If the cursor’s source or effective object store has been deleted, throw an "InvalidStateError" DOMException.
- ~IF[ 此れの`値取得済~flag$Cs ~EQ ~OFF ] ⇒ ~THROW `InvalidStateError$E ◎ If this cursor’s got value flag is unset, indicating that the cursor is being iterated or has iterated past its end, throw an "InvalidStateError" DOMException.
-
~IF[ %key ~NEQ ε ]: ◎ If key is given, then:
- %key ~LET `Key$( %key ) ? ◎ Let r be the result of running the steps to convert a value to a key with key. Rethrow any exceptions. ◎ If r is invalid, throw a "DataError" DOMException. ◎ Let key be r.
- ~IF[ %key ~LTE~cmpkey 此れの`位置$Cs ]~AND[ 此れの`方向$Cs ~IN { `next^l, `nextunique^l } ] ⇒ ~THROW `DataError$E ◎ If key is less than or equal to this cursor’s position and this cursor’s direction is "next" or "nextunique", throw a "DataError" DOMException.
- ~IF[ %key ~GTE~cmpkey 此れの`位置$Cs ]~AND[ 此れの`方向$Cs ~IN { `prev^l, `prevunique^l } ] ⇒ ~THROW `DataError$E ◎ If key is greater than or equal to this cursor’s position and this cursor’s direction is "prev" or "prevunique", throw a "DataError" DOMException.
- 此れの`値取得済~flag$Cs ~SET ~OFF ◎ Unset the got value flag on the cursor.
- %要請 ~SET 此れの`要請$Cs ◎ Let request be the request created when this cursor was created.
- %要請 の`~done~flag$ ~SET ~OFF ◎ Unset the done flag on request.
- %演算 ~SET 次を入力に `~cursorを反復-$する`演算$ ⇒# %cursor ~SET 此れ, %宛先~Realm ~SET `現在の~Realm$, %key ~SET %key ◎ ↓
- %要請 を用いて,此れの`~source$Cs上で %演算 を`非同期に実行する$ ◎ Run the steps to asynchronously execute a request with the cursor’s source as source, the steps to iterate a cursor as operation and request, using the current Realm as targetRealm, this cursor and key (if given).
注記: `advance$m の注記と同じ文言がこの~methodにも該当する。 ◎ Calling this method more than once before new cursor data has been loaded - for example, calling continue() twice from the same onsuccess handler - results in an "InvalidStateError" DOMException being thrown on the second call because the cursor’s got value flag has been unset.
- `continuePrimaryKey(key, primaryKey)@m
-
被呼出時には、~MUST_RUN: ◎ The continuePrimaryKey(key, primaryKey) method, when invoked, must run these steps:
- `CheckState$( 此れ ) ? ◎ Let transaction be this cursor’s transaction. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException. ◎ If the cursor’s source or effective object store has been deleted, throw an "InvalidStateError" DOMException.
- ~IF[ 此れの`~source$Csは`索引~handle$でない ] ⇒ ~THROW `InvalidAccessError$E ◎ If this cursor’s source is not an index throw an "InvalidAccessError" DOMException.
- ~IF[ 此れの`方向$Cs ~NIN { `next^l, `prev^l } ] ⇒ ~THROW `InvalidAccessError$E ◎ If this cursor’s direction is not "next" or "prev", throw an "InvalidAccessError" DOMException.
- ~IF[ 此れの`値取得済~flag$Cs ~EQ ~OFF ] ⇒ ~THROW `InvalidStateError$E ◎ If this cursor’s got value flag is unset, indicating that the cursor is being iterated or has iterated past its end, throw an "InvalidStateError" DOMException.
- %key ~LET `Key$( %key ) ? ◎ Let r be the result of running the steps to convert a value to a key with key. Rethrow any exceptions. ◎ If r is invalid, throw a "DataError" DOMException. ◎ Let key be r.
- %主key ~LET `Key$( %primaryKey ) ? ◎ Let r be the result of running the steps to convert a value to a key with primaryKey. Rethrow any exceptions. ◎ If r is invalid, throw a "DataError" DOMException. ◎ Let primaryKey be r.
- ~IF[ 此れの`方向$Cs ~EQ `next^l ]~AND[ ( %key, %主key ) ~LTE~cmpkey 此れの ( `位置$Cs, `保管庫~位置$Cs ) ] ⇒ ~THROW `DataError$E ◎ ↓
- ~IF[ 此れの`方向$Cs ~EQ `prev^l ]~AND[ ( %key, %主key ) ~GTE~cmpkey 此れの ( `位置$Cs, `保管庫~位置$Cs ) ] ⇒ ~THROW `DataError$E ◎ If key is less than this cursor’s position and this cursor’s direction is "next", throw a "DataError" DOMException. ◎ If key is greater than this cursor’s position and this cursor’s direction is "prev", throw a "DataError" DOMException. ◎ If key is equal to this cursor’s position and primaryKey is less than or equal to this cursor’s object store position and this cursor’s direction is "next", throw a "DataError" DOMException. ◎ If key is equal to this cursor’s position and primaryKey is greater than or equal to this cursor’s object store position and this cursor’s direction is "prev", throw a "DataError" DOMException.
- 此れの`値取得済~flag$Cs ~SET ~OFF ◎ Unset the got value flag on the cursor.
- %要請 ~SET 此れの`要請$Cs ◎ Let request be the request created when this cursor was created.
- %要請 の`~done~flag$ ~SET ~OFF ◎ Unset the done flag on request.
- %演算 ~SET 次を入力に `~cursorを反復-$する`演算$ ⇒# %cursor ~SET 此れ, %宛先~Realm ~SET `現在の~Realm$, %key ~SET %key, %主key ~SET %主key ◎ ↓
- %要請 を用いて,此れの`~source$Cs上で %演算 を`非同期に実行する$ ◎ Run the steps to asynchronously execute a request with the cursor’s source as source, the steps to iterate a cursor as operation and request, using the current Realm as targetRealm, this cursor, key and primaryKey.
注記: `advance$m の注記と同じ文言がこの~methodにも該当する。 ◎ Calling this method more than once before new cursor data has been loaded - for example, calling continuePrimaryKey() twice from the same onsuccess handler - results in an "InvalidStateError" DOMException being thrown on the second call because the cursor’s got value flag has been unset.
以下に挙げる~methodは、[ `~readonly~tx$の中で~callされた場合は `ReadOnlyError$E / `~tx$が`作動中$でないときに~callされた場合は `TransactionInactiveError$E ]を投出する。 ◎ The following methods throw a "ReadOnlyError" DOMException if called within a read-only transaction, and a "TransactionInactiveError" DOMException if called when the transaction is not active.
- %request = %cursor . `update$m(%value)
- %cursor が指している`~record$†の値を %value に更新するよう要請する。 ◎ Updated the record pointed at by the cursor with a new value.
- 【† `~source$Csが`索引$の場合は、その`参照先~record$。 】
- %cursor の`実効~保管庫$Csは`~key~path$Osを持っていて,`~key$を変更しようとした場合†、 `DataError$E が投出される。 ◎ Throws a "DataError" DOMException if the effective object store uses in-line keys and the key would have changed.
- 【† すなわち,当の~recordの~keyが %value 内の`~key~path$Osが指す部位と等しくない場合。 】
- 成功した場合の %request の `result$m は、更新した`~record$の`~key$になる。 ◎ If successful, request’s result will be the record’s key.
- %request = %cursor . `delete$m()
- %cursor が指している~recordを削除するよう要請する。 ◎ Delete the record pointed at by the cursor with a new value.
- 成功した場合の %request の `result$m は、 `undefined^js になる。 ◎ If successful, request’s result will be undefined.
- `update(value)@m
-
被呼出時には、~MUST_RUN: ◎ The update(value) method, when invoked, must run these steps:
- `CheckState$( 此れ, `readwrite^l ) ? ◎ Let transaction be this cursor’s transaction. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException. ◎ If transaction is a read-only transaction, throw a "ReadOnlyError" DOMException. ◎ If the cursor’s source or effective object store has been deleted, throw an "InvalidStateError" DOMException.
- ~IF[ 此れの`値取得済~flag$Cs ~EQ ~OFF ] ⇒ ~THROW `InvalidStateError$E ◎ If this cursor’s got value flag is unset, indicating that the cursor is being iterated or has iterated past its end, throw an "InvalidStateError" DOMException.
- ~IF[ 此れの`~key~only~flag$Cs ~EQ ~ON ] ⇒ ~THROW `InvalidStateError$E ◎ If this cursor’s key only flag is set, throw an "InvalidStateError" DOMException.
- %clone ~LET `Clone$( %value ) ? ◎ Let targetRealm be a user-agent defined Realm. ◎ Let clone be a clone of value in targetRealm. Rethrow any exceptions. ◎ Why create a copy of the value? ◎ The value is serialized when stored. Treating it as a copy here allows other algorithms in this specification to treat it as an ECMAScript value, but implementations can optimize this if the difference in behavior is not observable.
- %keyPath ~LET 此れの`実効~保管庫$Csの`~key~path$Os
-
~IF[ %keyPath ~NEQ ε ]: ◎ If the effective object store of this cursor uses in-line keys, then:
- %抽出~key ~LET `Extract$( %clone, %keyPath ) ? ◎ Let kpk be the result of running the steps to extract a key from a value using a key path with clone and the key path of the effective object store. Rethrow any exceptions. ◎ If kpk is failure, invalid, or not equal to the cursor’s effective key, throw a "DataError" DOMException.
- ~IF[ %抽出~key ~NEQ~cmpkey ~cursorの`実効~key$Cs ] ⇒ ~THROW `DataError$E ◎ ↑
- %演算 ~SET 次を入力に `保管庫に~recordを格納する$`演算$ ⇒# %保管庫 ~SET 此れの`実効~保管庫$Cs, %値 ~SET %clone, %key ~SET 此れの`実効~key$Cs, %上書不可~flag ~SET ~OFF ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this cursor as source and the steps to store a record into an object store as operation, using this cursor’s effective object store as store, the clone as value, this cursor’s effective key as key, and with the no-overwrite flag unset.
-
~RET 此れの`~source$Cs上で %演算 を`非同期に実行する新たな要請$ ◎ ↑
注記: `保管庫に~recordを格納する$演算は、~cursorが指す位置へ移動してから その位値の~recordが削除されていた場合、新たな~recordを作成させることになる。 ◎ A result of running the steps to store a record into an object store is that if the record has been deleted since the cursor moved to it, a new record will be created.
- `delete()@m
-
被呼出時には、~MUST_RUN: ◎ The delete() method, when invoked, must run these steps:
- `CheckState$( 此れ, `readwrite^l ) ? ◎ Let transaction be this cursor’s transaction. ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException. ◎ If transaction is a read-only transaction, throw a "ReadOnlyError" DOMException. ◎ If the cursor’s source or effective object store has been deleted, throw an "InvalidStateError" DOMException.
- ~IF[ 此れの`値取得済~flag$Cs ~EQ ~OFF ] ⇒ ~THROW `InvalidStateError$E ◎ If this cursor’s got value flag is unset, indicating that the cursor is being iterated or has iterated past its end, throw an "InvalidStateError" DOMException.
- ~IF[ 此れの`~key~only~flag$Cs ~EQ ~ON ] ⇒ ~THROW `InvalidStateError$E ◎ If this cursor’s key only flag is set, throw an "InvalidStateError" DOMException.
- %演算 ~SET 次を入力に `保管庫から~recordを削除する$`演算$ ⇒# %保管庫 ~SET 此れの`実効~保管庫$Cs, %key ~SET `Only$( 此れの`実効~key$Cs ) ◎ ↓
- ~RET 此れの`~source$Cs上で %演算 を`非同期に実行する新たな要請$ ◎ Run the steps to asynchronously execute a request and return the IDBRequest created by these steps. The steps are run with this cursor as source and the steps to delete records from an object store as operation, using this cursor’s effective object store and effective key as store and key respectively.
`~key~only~flag$Cs ~EQ ~OFF の`~cursor$は `IDBCursorWithValue$I ~interfaceも実装する。 ◎ A cursor that has the key only flag unset implements the IDBCursorWithValue interface as well.
[`Exposed$=(Window,Worker)] interface `IDBCursorWithValue@I : `IDBCursor$I { readonly attribute any `value$m; };
- %cursor . `value$m
- %cursor の現在の`値$Csを返す。 ◎ Returns the cursor’s current value.
- `value@m
- 取得子は、[ 此れの`値$Cs ~NEQ ε ならば それ / ~ELSE_ `undefined^js ]を返さ~MUST。 この属性にも `key^m 属性にて述べたこと が該当する。 ◎ The value attribute’s getter must return the cursor’s current value. Note that if this property returns an object, it returns the same object instance every time it is inspected, until the cursor’s value is changed. This means that if the object is modified, those modifications will be seen by anyone inspecting the value of the cursor. However modifying such an object does not modify the contents of the database.
4.9. `IDBTransaction^I ~interface
`~tx$は、次の~interfaceを実装する~objで表現される: ◎ transaction objects implement the following interface:
[`Exposed$=(Window,Worker)]
interface `IDBTransaction@I : `EventTarget$I {
readonly attribute `DOMStringList$I `objectStoreNames$m;
readonly attribute `IDBTransactionMode$I `mode$m;
[`SameObject$] readonly attribute `IDBDatabase$I `db$m;
readonly attribute `DOMException$I `error$m;
`IDBObjectStore$I `objectStore$m(DOMString %name);
void `abort$m();
// ~event~handler:
attribute `EventHandler$I `onabort$m;
attribute `EventHandler$I `oncomplete$m;
attribute `EventHandler$I `onerror$m;
};
enum `IDBTransactionMode@I {
`readonly$l,
`readwrite$l,
`versionchange$l
};
- %transaction . `objectStoreNames$m
- %transaction の`視野$に入る`保管庫$たちの名前からなる~listを返す。 `昇格~tx$に対しては、視野は,当の`~db$の`保管庫$すべてからなる。 ◎ Returns a list of the names of object stores in the transaction’s scope. For an upgrade transaction this is all object stores in the database.
- %transaction . `mode$m
- %transaction の`~mode$を返す。 `昇格~tx$に対しては, `versionchange$l / 他の~txに対しては,その作成-時に与えたもの( `readonly$l / `readwrite$l )になる。 ◎ Returns the mode the transaction was created with ("readonly" or "readwrite"), or "versionchange" for an upgrade transaction.
- %transaction . `db$m
- %transaction が`専属する$`接続$を返す。 ◎ Returns the transaction’s connection.
- %transaction . `error$m
- %transaction が すでに`中止-$されている場合、その事由を供する~error( `DOMException$I )を返す。 ◎ If the transaction was aborted, returns the error (a DOMException) providing the reason.
- `objectStoreNames@m
-
取得子は、~MUST_RUN: ◎ The objectStoreNames attribute’s getter must run these steps:
- %保管庫~集合 ~LET [ 此れは`昇格~tx$であるならば 此れが`専属する$`接続$の`保管庫~集合$Cn / ~ELSE_ 此れが`視野$に入れている`保管庫$たち ] ◎ ↓
- ~RET `SortedList$( %保管庫~集合 内の すべての`保管庫$の`名前$Os ) ◎ If this transaction is an upgrade transaction, return a DOMStringList associated with a sorted name list of the names of the object stores in this transaction's connection's object store set. ◎ Otherwise, return a DOMStringList associated with a sorted name list of the names of the object stores in this transaction's scope.
- 注記: この属性は、いつも同じ内容の~listを返す — ただし,`昇格~tx$の間は、保管庫が作成-/削除されるに伴い,異なる内容の~listを返し得る。 ◎ The contents of each list returned by this attribute does not change, but subsequent calls to this attribute during an upgrade transaction can return lists with different contents as object stores are created and deleted.
- `mode@m
- 取得子は、此れの`~mode$を返さ~MUST。 ◎ The mode attribute’s getter must return the mode of the transaction.
- `db@m
- 取得子は、此れが`専属する$`接続$を返さ~MUST。 ◎ The db attribute’s getter must return the database connection of which this transaction is a part.
- `error@m
- 取得子は、[ 此れの`~error$tx ~NEQ ε ならば それ / ~ELSE_ ~NULL ]を返さ~MUST。 ◎ The error attribute’s getter must return this transaction’s error, or null if none.
-
注記: ~txが中止されたときは、その事由に応じて,次を返す:
- 失敗した`要請$に因り`中止-$された場合、`要請$の`~error$と同じ名前の~error。
- ~event~handlerから投出された例外に因り`中止-$された場合、 `AbortError$E
- `~commit$時の~errorに因り`中止-$された場合、失敗の事由を反映する~error — 例えば `QuotaExceededError$E / `ConstraintError$E / `UnknownError$E
【 `abort()$m ~methodに因り`中止-$された場合は、 ~NULL が返される。 】
◎ If this transaction was aborted due to a failed request, this will be the same as the request’s error. If this transaction was aborted due to an uncaught exception in an event handler, the error will be a "AbortError" DOMException. If the transaction was aborted due to an error while committing, it will reflect the reason for the failure (e.g. "QuotaExceededError", "ConstraintError", or "UnknownError" DOMException).
- %transaction . `objectStore$m(%name)
- %transaction の`視野$に入る`名前$Os %name の`保管庫$を`~access先$とする `IDBObjectStore$I を返す。 ◎ Returns an IDBObjectStore in the transaction’s scope.
- %transaction . `abort()$m
- %transaction を中止する。 処理待ちにあるすべての`要請$は `AbortError$E で失敗し、接続先~dbに加えられた すべての変更は復帰されることになる。 ◎ Aborts the transaction. All pending requests will fail with a "AbortError" DOMException and all changes made to the database will be reverted.
- `objectStore(name)@m
-
被呼出時には、~MUST_RUN: ◎ The objectStore(name) method, when invoked, must run these steps:
- ~IF[ 此れはすでに`終了-$した ] ⇒ ~THROW `InvalidStateError$E ◎ If transaction has finished, throw an "InvalidStateError" DOMException.
- %保管庫 ~LET 此れの`視野$に入る~AND[ `名前$Os ~EQ %name ]なる`保管庫$ ◎ ↓
- ~IF[ %保管庫 ~EQ ε ] ⇒ ~THROW `NotFoundError$E ◎ Let store be the object store named name in this transaction’s scope, or throw a "NotFoundError" DOMException if none.
- ~RET 次を満たすような`保管庫~handle$ %H ⇒# %H↗ ~EQ %保管庫, %H は此れに`専属する$, `一意性$の要件を満たす(`可換性$の要件は、`視野$の構成から自動的に満たされる) ◎ Return an object store handle associated with store and this transaction.
注記: `一意性$の要件から,返される~instanceは一意に定まる 【~instanceがその前のどの時点で作成されるかは,実装の詳細になる】 。 よって、`昇格~tx$の間を除き、同じ `IDBTransaction$I ~instance上で,同じ %name をこの~methodに渡して返される `IDBObjectStore$I ~instanceは、常に同じになる。 ◎ Each call to this method on the same IDBTransaction instance with the same name returns the same IDBObjectStore instance.
注記: %H は此れに`専属する$ので、他の `IDBTransaction$I ~instanceに対し同じ引数で この~methodを呼出しても, %H と異なる `IDBObjectStore$I ~instanceが返される。 ◎ The returned IDBObjectStore instance is specific to this IDBTransaction. If this method is called on a different IDBTransaction, a different IDBObjectStore instance is returned.
- `abort()@m
-
被呼出時には、~MUST_RUN: ◎ The abort() method, when invoked, must run these steps:
- ~IF[ 此れはすでに`終了-$した ] ⇒ ~THROW `InvalidStateError$E ◎ If this transaction is finished, throw an "InvalidStateError" DOMException.
- 此れの`作動中~flag$ ~SET ~OFF ◎ Unset the transaction’s active flag and\
- 次を入力に `~txを中止-$する ⇒ %~tx ~SET 此れ ◎ run the steps to abort a transaction with null as error.
- `onabort@m
- `abort$et ~event用の~event~handler。 ◎ The onabort attribute is the event handler for the abort event.
- `oncomplete@m
- `complete$et ~event用の~event~handler。 ◎ The oncomplete attribute is the event handler for the complete event.
- `onerror@m
- `error$et ~event用の~event~handler。 ◎ The onerror attribute is the event handler for the error event.
注記: `~tx$が成功裡に完了したかどうかは、要請に配送される `success$et ~eventではなく,`~tx$に配送される `complete$et ~eventを~listenして決定すること — `~tx$は、 `success$et ~eventを発火した後でも失敗し得るので。 ◎ To determine if a transaction has completed successfully, listen to the transaction’s complete event rather than the success event of a particular request, because the transaction can still fail after the success event fires.
X. この訳に固有の各種~algo
【 この節では、原文~仕様の各種~API定義に繰り返し現れる記述を集約して定義する。 集約~以外にも、~APIの演算において即時に行われる演算(失敗した場合は例外が投出される, この節にて述べるもの)と, `要請$にて非同期に行われる演算(失敗は~eventを通して通知される)とを区別して,挙動を明快にする目的もある。 】
X.1. Error( %~error名 )
名前 %~error名 の新たな `DOMException$I ~objを 作成して 返す。
X.2. Flag( %b )
所与の~IDL `boolean^I 型~値を~flag値に変換する ⇒ %b に応じて[ ~T ならば ~ON / ~F ならば ~OFF ]を返す。
X.3. Bool( %~flag )
所与の~flag値を~IDL `boolean^I 型~値に変換する ⇒ %~flag に応じて[ ~ON ならば ~T / ~OFF ならば ~F ]を返す。
X.4. SortedList( %集合 )
次が結付けられた `DOMStringList$I ~objを返す ⇒ 所与の`名前$の集合 %集合 を`整列-済み名前~list$にした結果
X.5. Clone( %値 )
%値 を ~UAにより定義される`~Realm$内で`~clone$した結果を返す。
注記: 値を複製するわけは: 値は格納-時に直列化される。 ここで複製として扱うことにより、この仕様~内の他の~algoは,それを~JS値として扱えるようになる。 実装は、異なる挙動が観測され得ないならば,これを最適化できる。 ◎ Why create a copy of the value? ◎ The value is serialized when stored. Treating it as a copy here allows other algorithms in this specification to treat it as an ECMAScript value, but implementations can optimize this if the difference in behavior is not observable.
X.6. ~cursorを作成する手続き
次で与えられる:
- %source : `保管庫~handle$/`索引~handle$
- %方向 : `方向$Cs
- %範囲: `~key範囲$
- %~key~only~flag: ~flag値
- %cursor ~LET 次の様にされた,新たな`~cursor$ ⇒# `要請$Cs ~SET この手続きを`演算$として呼出した`要請$, `~source$Cs ~SET %source, `範囲$Cs ~SET %範囲, `方向$Cs ~SET %方向, `位置$Cs ~SET ε, `保管庫~位置$Cs ~SET ε, `~key$Cs ~SET ε, `値$Cs ~SET ε, `値取得済~flag$Cs ~SET ~OFF, `~key~only~flag$Cs ~SET %~key~only~flag
- %cursor ~LET 次を入力に `~cursorを反復-$した結果 ⇒# %cursor ~SET %cursor, %宛先~Realm ~SET `現在の~Realm$
- ~IF[ %cursor ~EQ ~NULL ] ⇒ ~RET ~NULL
- ~IF[ %~key~only~flag ~EQ ~ON ] ⇒ ~RET %cursor を表現する `IDBCursor!I ~obj
- ~RET %cursor を表現する `IDBCursorWithValue!I ~obj
X.7. CheckState( %O, %要求mode )
%O を通して `保管庫$または`索引$に[ ~accessし得るかどうか, および演算し得るかどうか ]を検査する:
-
~IF[ %O は`~cursor$である ]:
- %O ~SET %O の`~source$Cs
- 下の手続きを `段 A^i, `段 C^i, `段 B^i の順に実行する
- ~RET
-
`段 A^i:
- %transaction ~LET %O が`専属する$~tx
- ~IF[ %要求mode ~EQ `versionchange^l ]~AND[ %transaction は`昇格~tx$でない ] ⇒ ~THROW `InvalidStateError$E ◎ If transaction is not an upgrade transaction, throw an "InvalidStateError" DOMException.
-
`段 B^i:
- ~IF[ %O↗ はすでに削除されている ] ⇒ ~THROW `InvalidStateError$E ◎ If index or index’s object store has been deleted, throw an "InvalidStateError" DOMException. ◎ If store has been deleted, throw an "InvalidStateError" DOMException.
-
`段 C^i:
- ~IF[ %transaction は`作動中$でない ] ⇒ ~THROW `TransactionInactiveError$E ◎ If transaction is not active, throw a "TransactionInactiveError" DOMException.
- ~IF[ %要求mode ~EQ `readwrite^l ]~AND[ %transaction は`~readonly~tx$である ] ⇒ ~THROW `ReadOnlyError$E ◎ If transaction is a read-only transaction, throw a "ReadOnlyError" DOMException.
【 原文では、 `IDBIndex.name$m, `IDBObjectStore.name$m の設定子については、上の手続きを他と異なる順序で検査するように記述されている(この2つについても互いに異なる — 単なる誤記かも?)。 詳細は原文を参照されたし。 現実の実装も,上のものと一致するとは限らない(各~実装, 各~methodごとにまちまちな部分もあるかもしれない)。 】
X.8. Value( %key )
所与の[ `~key$ または ε ]を値に変換した結果を返す:
- ~IF[ %key ~EQ ε ] ⇒ ~RET `undefined^js
- ~RET `Value1$( %key )
X.9. Key( %input )
所与の値 %input を`~key$に変換した結果を返すか, または例外を`投出-$する:
- %~key ~LET `Key1$( %input )
- ~IF[ %~key ~EQ ~invalid ] ⇒ ~THROW `DataError$E
- ~IF[ %~key は`例外である$ ] ⇒ ~THROW その例外
- ~RET %~key
X.10. Extract( %値, %keyPath, %生成器 )
所与の ( `値$, `~key~path$, `~key生成器$ ) に対し,例外を`投出-$するか, または[ `~key$ / ε ]を返す:
- %抽出~key ~LET `ExtractKey$ ( %値, %keyPath )
-
%抽出~key に応じて:
- `例外である$
- ~THROW その例外
- `~key$である
- ~RET %抽出~key
- ~invalid
- ~THROW `DataError$E
- ~failure
-
- ~IF[ %生成器 ~EQ ε ] ⇒ ~THROW `DataError$E
- ~RET ε
X.11. Dispatch( %標的, %~event )
%~event を配送した上で,~flag値を返す:
- `旧来の(~listenerは投出したか?)~flag^V ~LET ~OFF
- `旧来の(~listenerは投出したか?)~flag^V †も渡して, %標的 に向けて %~event を`配送する$ (†この~flagは、参照として渡される。)
- ~RET `旧来の(~listenerは投出したか?)~flag^V
5. 各種~algo
5.1. ~dbの~open法
`~dbを~open@ する手続きは、次で与えられる:
- %生成元: `生成元$
- %名前: ~dbの`名前$db
- %~version: `~version$db
- %要請: `~open要請$
- %~queue ~LET ( %生成元, %名前 ) に対する`接続~queue$ ◎ Let queue be the connection queue for origin and name.
- %要請 を %~queue に追加する ◎ Add request to queue.
- %~queue 内の %要請 以前の要請すべてが処理されるまで待機する ◎ Wait until all previous requests in queue have been processed.
- %~db ~LET %生成元 に`専属する$`~db$であって, [ `名前$db ~EQ %名前 ]なるもの ◎ Let db be the database named name in origin, or null otherwise.
- ~IF [ %~version ~EQ ε ] ⇒ %~version ~SET [ %~db ~EQ ε ならば 1 / ~ELSE_ %~db の`~version$db ] ◎ If version is undefined, let version be 1 if db is null, or db’s version otherwise.
-
~IF [ %~db ~EQ ε ]:
- %~db ~LET 次の様にされた新たな`~db$ ⇒# %生成元 に`専属する$, `名前$db ~SET %名前, `~version$db ~SET `0^c , `専属する$`保管庫$はない
- ~IF[ 何らかの事由で前~段は失敗した ] ⇒ ~RET `Error$( 適切な~error名 ) — 例えば `QuotaExceededError$E / `UnknownError$E
- ~IF[ %~version ~LT %~db の`~version$db ] ⇒ ~RET `Error$( `VersionError$E ) ◎ If db’s version is greater than version, return a newly created "VersionError" DOMException and abort these steps.
- %新~接続 ~LET %~db を`~access先$とする新たな`接続$ ◎ Let connection be a new connection to db.
- %新~接続 の`~version$Cn ~SET %~version ◎ Set connection’s version to version.
-
~IF [ %~version ~GT %~db の`~version$db ]: ◎ If db’s version is less than version, then:
- `接続たち^V ~LET [ %~db を`~access先$とする`接続$のうち %新~接続 でないもの ]からなる集合 ◎ Let openConnections be the set of all connections, except connection, associated with db.
-
`接続たち^V 内の ~EACH( %接続 ) に対し ⇒ ~IF[ %接続 の`状態$Cn ~EQ `~open中$i ] ⇒ 次を走らす`~taskを~queueする$ ⇒ %接続 に向けて`~version変更~eventを発火する$( `versionchange$et, %~db の`~version$db, %~version ) ◎ For each entry in openConnections that does not have its close pending flag set, queue a task to fire a version change event named versionchange at entry with db’s version and version.
注記: この~eventの発火は、上の反復の途中で,いくつかの接続を`~close$させ得る。 それらの接続に向けては、まだ終えてなくとも `versionchange$et ~eventは発火されない。 ◎ Firing this event might cause one or more of the other objects in openConnections to be closed, in which case the versionchange event is not fired at those objects, even if that hasn’t yet been done.
- すべての~eventが発火されるまで待機する ◎ Wait for all of the events to be fired.
- ~IF[ `接続たち^V 内に,[ `状態$Cn ~NEQ `~close済み$i ]なる`接続$が依然としてある ] ⇒ 次を走らす`~taskを~queueする$ ⇒ %新~接続 に向けて`~version変更~eventを発火する$( `blocked$et, %~db の`~version$db, %~version ) ◎ If any of the connections in openConnections are still not closed, queue a task to fire a version change event named blocked at request with db’s version and version.
- `接続たち^V 内のすべての`接続$について,[ その`状態$Cn ~EQ `~close済み$i ]になるまで,待機する ◎ Wait until all connections in openConnections are closed.
-
次を入力に `昇格~txを稼働-$する ⇒# %接続 ~SET %新~接続, %~version ~SET %~version, %要請 ~SET %要請 ◎ Run the steps to run an upgrade transaction using connection, version and request.
【 `昇格~tx$が`終了-$するまで待機した上で 】
- [ %新~接続 の`状態$Cn ~EQ `~close済み$i ]になったときは ⇒ ~RET `Error$( `AbortError$E ) ◎ If connection was closed, return a newly created "AbortError" DOMException and abort these steps.
-
`昇格~tx$が中止されたときは:
- 次を入力に `~db接続を~close$する ⇒ %接続 ~SET %新~接続
- ~RET `Error$( `AbortError$E )
- ~RET %新~接続 ◎ Return connection.
5.2. ~dbの~close法
`~db接続を~close@ する手続きは、次で与えられる:
- %接続: `接続$
- %強制~flag
- %接続 の`状態$Cn ~SET `~close待ち$i ◎ Set the close pending flag of connection.
- `~txたち^V ~LET [ %接続 に`専属する$`~tx$であって, `終了-$していないもの ]からなる集合 ◎ ↓
- ~IF[ %強制~flag ~EQ ~ON ] ⇒ `~txたち^V 内の ~EACH( `~tx$ %~tx ) に対し ⇒ 次を入力に `~txを中止-$する ⇒# %~tx ~SET %~tx, %error ~SET `AbortError$E ◎ If the forced flag is set, then for each transaction created using connection run the steps to abort a transaction with transaction and newly created "AbortError" DOMException.
- `~txたち^V 内の すべての~txが`終了-$するまで待機する ◎ Wait for all transactions created using connection to complete.\
- %接続 の`状態$Cn ~SET `~close済み$i ◎ Once they are complete, connection is closed.
-
~IF %強制~flag ~EQ ~ON ⇒ %接続 に向けて,名前 `close$et の`~eventを発火する$ ◎ If the forced flag is set, then fire an event named close at connection.
注記: `close$et ~eventが発火されるのは、接続が異常に~closeされた場合に限られる — 例えば: 生成元に対する蓄積が消去された場合 / 何かが壊れたとき / I/O ~errorが生じたとき。 明示的に `close()$m を~callした場合には、この~eventは発火されない。 ◎ The "close" event only fires if the connection closes abnormally, e.g. if the origin’s storage is cleared, or there is corruption or an I/O error. If close() is called explicitly the event does not fire.
注記: %接続 の`状態$Cnが `~close待ち$i にされて以降は、[ %接続 を利用して,新たな`~tx$を`作成-$する ]ことはできなくなる。 ~txを`作成-$する すべての~methodは、最初に %接続 の`状態$Cnを検査した上で, `~open中$i でないならば例外を投出する。 ◎ Once the close pending flag has been set no new transactions can be created using connection. All methods that create transactions first check the close pending flag first and throw an exception if it is set.
注記: `接続$が~closeされたとき、所与の`~db$への`接続$がすべて~closeされるまで, 阻まれ, 待機~中にあった[ `昇格~txを稼働-$する演算/ `~dbを削除-$する演算 ]の待機は、解かれ得る。 ◎ Once the connection is closed, this can unblock the steps to run an upgrade transaction, and the steps to delete a database, which both wait for connections to a given database to be closed before continuing.
5.3. ~dbの削除-法
`~dbを削除-@ する手続きは、次で与えられる:
- %生成元: `生成元$
- %名前: `~db$の`名前$db
- %要請: `~open要請$
- %~queue ~LET ( %生成元, %名前 ) に対する`接続~queue$ ◎ Let queue be the connection queue for origin and name.
- %要請 を %~queue に追加する ◎ Add request to queue.
- %~queue 内の %要請 以前の要請すべてが処理されるまで待機する ◎ Wait until all previous requests in queue have been processed.
- %~db ~LET %生成元 に`専属する$`~db$であって, [ `名前$db ~EQ %名前 ]なるもの ◎ Let db be the database named name in origin, if one exists.\
- ~IF[ %~db ~EQ ε ] ⇒ ~RET 0 ◎ Otherwise, return 0 (zero).
- `接続たち^V ~LET [ %~db を`~access先$とする`接続$ ]のうち[ `状態$Cn ~NEQ `~close済み$i ]を満たすものからなる集合 ◎ Let openConnections be the set of all connections associated with db.
-
`接続たち^V 内の ~EACH( %接続 ) に対し ⇒ ~IF[ %接続 の`状態$Cn ~EQ `~open中$i ] ⇒ 次を走らす`~taskを~queueする$ ⇒ %接続 に向けて`~version変更~eventを発火する$( `versionchange$et, %~db の`~version$db, ~NULL ) ◎ For each entry in openConnections that does not have its close pending flag set, queue a task to fire a version change event named versionchange at entry with db’s version and null.
注記: ここでも,~dbの~open法と同様の注記 が該当する。 ◎ Firing this event might cause one or more of the other objects in openConnections to be closed, in which case the versionchange event is not fired at those objects, even if that hasn’t yet been done.
- すべての~eventが発火されるまで待機する ◎ Wait for all of the events to be fired.
- ~IF[ `接続たち^V 内に[ `状態$Cn ~NEQ `~close済み$i ]なる`接続$は依然としてある ] ⇒ 次を走らす`~taskを~queueする$ ⇒ %要請 に向けて`~version変更~eventを発火する$( `blocked$et, %~db の`~version$db, ~NULL ) ◎ If any of the connections in openConnections are still not closed, queue a task to fire a version change event named blocked at request with db’s version and null.
- `接続たち^V 内のすべての`接続$について,[ その`状態$Cn ~EQ `~close済み$i ]になるまで,待機する ◎ Wait until all connections in openConnections are closed.
- %~version ~LET %~dbの `~version$db ◎ Let version be db’s version.
- %~db を削除する ◎ Delete db.\
- ~IF[ 何らかの事由で前~段は失敗した ] ⇒ ~RET `Error$( 適切な~error名 ) — 例えば `QuotaExceededError$E / `UnknownError$E ◎ If this fails for any reason, return an appropriate error (e.g. "QuotaExceededError" or "UnknownError" DOMException).
- ~RET %~version ◎ Return version.
5.4. ~txの~commit法
`~txを~commit@ する手続きは、次で与えられる:
- %~tx: ~commitする`~tx$
- %~db ~LET ( %~tx が`専属する$`接続$ )↗ ◎ ↓
- %~tx により発行0された すべての変更を、 %~db に書込する: ◎ All the changes made to the database by transaction are written to the database.
- ~IF[ 前~段による書込み時に~errorが生じた ] ⇒ 次を入力に `~txを中止-$する ⇒# %~tx ~SET %~tx, %error ~SET その~errorに適切な~error名 — 例えば `QuotaExceededError$E / `UnknownError$E ◎ If an error occurs while writing the changes to the database, abort the transaction by following the steps to abort a transaction with transaction and an appropriate for the error, for example "QuotaExceededError" or "UnknownError" DOMException.
-
次を走らす`~taskを~queueする$: ◎ Queue a task to run these steps:
- ~IF[ %~tx は`昇格~tx$である ] ⇒ %~db の`昇格~tx$db ~SET ε ◎ If transaction is an upgrade transaction, set the database's upgrade transaction to null.
-
%~tx に向けて,名前 `complete$et の`~eventを発火する$ ◎ Fire an event named complete at transaction.
注記: この~event用の~event~handlerから例外が投出されても、~db変更の書込みは~eventの配送-前に終わるので,~txは~commitされる。 `complete$et ~eventが発火されるのは、~txが成功裡に書込されてから限られる。 ◎ Even if an exception is thrown from one of the event handlers of this event, the transaction is still committed since writing the database changes happens before the event takes places. Only after the transaction has been successfully written is the "complete" event fired.
- ~IF[ %~tx は`昇格~tx$である ] ⇒ [ %~tx を`設置先~tx$とする`要請$(すなわち、`昇格~txを稼働-$する手続きに渡された %要請 ) ]の`設置先~tx$ ~SET ε ◎ If transaction is an upgrade transaction, then let request be the request associated with transaction and set request’s transaction to null.
【 `~readonly~tx$に対してもこの手続は呼出されるのかどうか? はっきりしない(呼出された方が~txの`終了-$時も検出し易いが)。 】
5.5. ~txの中止-法
`~txを中止-@ する手続きは、次で与えられる:
- %~tx: 中止する`~tx$
- %error : ~error名(省略時は ε )
- %~db ~LET ( %~tx が`専属する$`接続$ )↗ ◎ ↓
-
%~tx により %~db に発行0された,すべての変更を、復帰させる — `昇格~tx$に対しては:
- %~db に`専属する$[ `保管庫$/`索引$ ]たちの集合, および`~version$dbの変更も,復帰させる。
- %~tx の間に作成された[ `保管庫$/`索引$ ]は、他の~algoの目的においては,削除されたものと見なされる。
-
~IF[ %~tx は`昇格~tx$である ] ⇒ 次を入力に `昇格~txを中止-$する ⇒ %~tx ~SET %~tx ◎ If transaction is an upgrade transaction, run the steps to abort an upgrade transaction with transaction.
注記: この結果、[ %~tx が`専属する$`接続$ / %~tx に`専属する$[ `保管庫~handle$ / `索引~handle$ ]]すべての~instanceに対する変更は復帰されることになる。 ◎ This reverts changes to all connection, object store handle, and index handle instances associated with transaction.
- ~IF[ %error ~NEQ ε ] ⇒ %~tx の`~error$tx ~SET `Error$( %error ) ◎ If error is not null, set transaction’s error to error.
-
%~tx の`要請~list$内の[ `~done~flag$ ~EQ ~OFF ]を満たす ~EACH( `要請$ %要請 ) に対し,順に: ◎ For each request in transaction’s request list with done flag unset,\
- %要請 を`非同期に実行する$手続きを中止する ◎ abort the steps to asynchronously execute a request for request and\
-
次を走らす`~taskを~queueする$: ◎ queue a task to run these steps:
- %要請 の`~done~flag$ ~SET ~ON ◎ Set the done flag on request.
- %要請 の`結果$ ~SET ε ◎ Set the result of request to undefined.
- %要請 の`~error$ ~SET `Error$( `AbortError$E ) ◎ Set the error of request to a newly created "AbortError" DOMException.
- %要請 に向けて,名前 `error$et の`~eventを発火する$ — 次のように初期化して ⇒# `bubbles$m 属性 ~SET ~T, `cancelable$m 属性 ~SET ~T ◎ Fire an event named error at request with its bubbles and cancelable attributes initialized to true.
注記: これは常に `error$et ~eventを発火させるとは限らない。 例えば~txを`~commit$している間に~errorに因り中止された場合や,それは失敗した最後の残りの要請であった場合 【?】。 ◎ This does not always result in any error events being fired. For example if a transaction is aborted due to an error while committing the transaction, or if it was the last remaining request that failed.
-
次を走らす`~taskを~queueする$: ◎ Queue a task to run these steps:
- ~IF[ %~tx は`昇格~tx$である ] ⇒ %~db の`昇格~tx$db ~SET ε ◎ If transaction is an upgrade transaction, set the database's upgrade transaction to null.
- %~tx に向けて,名前 `abort$et の`~eventを発火する$ — 次のように初期化して ⇒ `bubbles$m 属性 ~SET ~T ◎ Fire an event named abort at transaction with its bubbles attribute initialized to true.
-
~IF[ %~tx は`昇格~tx$である ]: ◎ If transaction is an upgrade transaction, then:
- %要請 ~LET %~tx を`設置先~tx$とする`要請$(すなわち、`昇格~txを稼働-$する手続きに渡された %要請 ) ◎ Let request be the request associated with transaction.
- %要請 の`設置先~tx$ ~SET ε ◎ Set request’s transaction to null.
- %要請 の`結果$ ~SET ε ◎ Set request’s result to undefined.
- %要請 の`~done~flag$ ~SET ~OFF ◎ Unset request’s done flag.
5.6. 要請の非同期的な実行-法
%source 上で %演算 を[ `非同期に実行する@ ための新たな要請を作成する手続き / 既存の %要請 を用いて 非同期に実行する 手続き ]は、次で与えられる:
- %source : `保管庫~handle$/`索引~handle$
- %演算: ~db上で遂行する`演算$
- %要請: `要請$(省略時は ε — その場合,新たな要請を作成することになる)
この手続きは、作成された`要請$の`設置先~tx$が`~txを中止-$する手続きを利用して`中止-$された場合、いつでも中止され得る。 ◎ These steps can be aborted at any point if the transaction the created request belongs to is aborted using the steps to abort a transaction.
- %~tx ~LET %source が`専属する$`~tx$ ◎ Let transaction be the transaction associated with source.
- ~Assert: %~tx は`作動中$である ◎ Assert: transaction is active.
- ~IF[ %要請 ~EQ ε ] ⇒ %要請 ~SET 次の様にされた`要請$を表現する,新たな `IDBRequest$I ~obj ⇒# `~source$ ~SET %source, `設置先~tx$ ~SET %~tx ◎ If request was not given, let request be a new request with source as source.
- %~tx の`要請~list$に %要請 を追加する ◎ Add request to the end of transaction’s request list.
- ~RET %要請 — ただし,以降も`並列的$に走らす ◎ Run these steps in parallel:
- %~tx の`要請~list$内の %要請 より前に設置された すべての要請について,それらの[ `~done~flag$ ~EQ ~ON ]になるまで待機する ◎ Wait until all previously added requests in transaction have their done flag set.
- %結果 ~LET %演算 を遂行した結果 ◎ Let result be the result of performing operation.
-
~IF[ %結果 は~errorである ]( %演算 は失敗した) ⇒ %演算 により生じたすべての変更を復帰する ◎ If result is an error, then revert all changes made by operation.
注記: これは、この要請により行われた変更のみを復帰させる。 ~txにより発行0された他の変更は復帰されない。 ◎ This only reverts the changes done by this request, not any other changes made by the transaction.
-
次を走らす`~taskを~queueする$: ◎ Queue a task to run these steps:
-
%要請 の ⇒# `~done~flag$ ~SET ~ON, `結果$ ~SET ε, `~error$ ~SET ε ◎ Set the done flag on request. ◎ ↓
-
~IF[ %結果 は~errorである ]: ◎ If result is an error, then:
- %要請 の`~error$ ~SET %結果 ◎ Set the result of request to undefined. ◎ Set the error of request to result.
- %要請 に向けて`~error~eventを発火する$ ◎ Fire an error event at request.
-
~ELSE: ◎ Otherwise:
- %要請 の`結果$ ~SET %結果 ◎ Set the result of request to result. ◎ Set the error of request to undefined.
- %要請 に向けて`~success~eventを発火する$ ◎ Fire a success event at request.
-
◎ ↑↑Return request.
5.7. 昇格~txの稼働-法
`昇格~txを稼働-@ する手続きは、次で与えられる:
- %接続: `~db$を更新するために利用する`接続$
- %~version: ~dbに設定する新たな~version
- %要請: `要請$
- %~db ~LET %接続↗ ◎ Let db be connection’s database.
- %~tx ~LET 次の様にされた新たな`昇格~tx$ ⇒# `専属する$`接続$ ~SET %接続, `視野$ ~SET %~db に`専属する$すべての`保管庫$ ◎ Let transaction be a new upgrade transaction with connection used as connection. The scope of transaction includes every object store in connection.
- %~db の`昇格~tx$db ~SET %~tx ◎ Set database’s upgrade transaction to transaction.
- %~tx の`作動中~flag$ ~SET ~OFF ◎ Unset transaction’s active flag.
-
%~tx を開始する ◎ Start transaction.
注記: この`~tx$が`終了-$するまで,他の`接続$は %~db を~openできないことに注意。 ◎ Note that until this transaction is finished, no other connections can be opened to the same database.
- %旧~version ~LET %~db の`~version$db ◎ Let old version be db’s version.
- %~db の`~version$db ~SET %~version — この変更は,`~tx$の一部と見なされ、~txが`中止-$された場合には復帰される。 ◎ Set the version of db to version. This change is considered part of the transaction, and so if the transaction is aborted, this change is reverted.
-
次を走らす`~taskを~queueする$: ◎ Queue a task to run these steps:
- %要請 の`結果$ ~SET %接続 ◎ Set request’s result to connection.
- %要請 の`設置先~tx$ ~SET %~tx ◎ Set request’s transaction to transaction.
- %要請 の`~done~flag$ ~SET ~OFF ◎ Set the done flag on the request.
- %~tx の`作動中~flag$ ~SET ~ON ◎ Set transaction’s active flag.
- `~listener投出あり^V ~LET %要請 に向けて`~version変更~eventを発火する$( `upgradeneeded$et, %旧~version, %~version ) ◎ Let didThrow be the result of running the steps to fire a version change event named upgradeneeded at request with old version and version.
- %~tx の`作動中~flag$ ~SET ~OFF ◎ Unset transaction’s active flag.
- ~IF[ `~listener投出あり^V ~EQ ~ON ] ⇒ 次を入力に`~txを中止-$する ⇒ %error ~SET `AbortError$E ◎ If didThrow is set, run the steps to abort a transaction with the error property set to a newly created "AbortError" DOMException.
-
%~tx が`終了-$するまで待機する ◎ Wait for transaction to finish.
注記: [ `~txを~commit$する/ `~txを中止-$する ]手続きなど,~txの存続期間に呼出される一部の~algoは、`昇格~tx$に特有の手続きを含む。 ◎ Some of the algorithms invoked during the transaction’s lifetime, such as the steps to commit a transaction and the steps to abort a transaction, include steps specific to upgrade transactions.
5.8. 昇格~txの中止-法
`昇格~txを中止-@ する手続きは、次で与えられる:
- %~tx : `昇格~tx$
注記: この手続きは,`~txを中止-$する手続き内で必要に応じて走らされ、`~db$に`専属する$[ `保管庫$/`索引$ ]たちの集合, および `~version$db変更を復帰させる。 【~APIに公開される部分を復帰させる。】 ◎ These steps are run as needed by the steps to abort a transaction, which revert changes to the database including the set of associated object stores and indexes, as well as the change to the version.
- %接続 ~LET %~tx が`専属する$`接続$ ◎ Let connection be transaction’s connection.
- %~db ~LET %接続↗ ◎ Let database be connection’s database.
-
%接続 の`~version$Cn ~SET %~db の`~version$db ( %~tx が %~db を新たに作成したのであれば 0 ) ◎ Set connection’s version to database’s version if database previously existed, or 0 (zero) if database was newly created.
注記: これは、 `IDBDatabase!I ~objから返される `version$m 値を復帰させる。 ◎ This reverts the value of version returned by the IDBDatabase object.
-
%接続 の`保管庫~集合$Cn ~SET %~db に`専属する$`保管庫$の集合 ( %~tx が %~db を新たに作成したのであれば 空~集合 ) ◎ Set connection’s object store set to the set of object stores in database if database previously existed, or the empty set if database was newly created.
注記: これは、 `IDBDatabase!I ~objから返される `objectStoreNames$m 値を復帰させる。 ◎ This reverts the value of objectStoreNames returned by the IDBDatabase object.
-
この段において反復される~handleたちには、その`~access先$が %~tx により削除-または作成されたものも含まれることに注意。 ◎ ↓
%~tx に`専属する$ ~EACH( `保管庫~handle$ %H ) に対し: ◎ For each object store handle handle associated with transaction, including those for object stores that were created or deleted during transaction:
- ~IF[ %H↗ は %~tx により作成されたものではない ] ⇒ %H の`名前$OsH ~SET %H↗ の`名前$Os ◎ If handle’s object store was not newly created during transaction, set handle’s name to its object store’s name.
-
%H の`索引~集合$OsH ~SET %H↗ に`専属する$`索引$たちの集合 ◎ Set handle’s index set to the set of indexes that reference its object store.
注記: これは、 %H (を表現する `IDBObjectStore!I ~obj)が返す[ `name$m, `indexNames$m ]値を復帰させる。 ◎ This reverts the values of name and indexNames returned by related IDBObjectStore objects.
~scriptは、 %~tx が中止されて以降も,依然として自身が持つ %H の[ `name$m / `indexNames$m ]属性は照会できる — %~tx の `objectStore()$m ~methodを利用しても, %H↗ には~accessできなくなるが。 ◎ How is this observable? ◎ Although script cannot access an object store by using the objectStore() method on an IDBTransaction instance after the transaction is aborted, it can still have references to IDBObjectStore instances where the name and indexNames properties can be queried.
-
%H に`専属する$ ~EACH( `索引~handle$ %I ) に対し: ◎ For each index handle handle associated with transaction, including those for indexes that were created or deleted during transaction:
- ~IF[ %I↗ は %~tx により作成されたものではない ] ⇒ %I の`名前$IxH ~SET %I↗ の`名前$Ix ◎ If handle’s index was not newly created during transaction, set handle’s name to its index’s name.
注記: これは、 %I (を表現する `IDBIndex!I ~obj)が返す `name$m 値を復帰させる。 ◎ This reverts the value of name returned by related IDBIndex objects.
~scriptは、 %~tx が中止されて以降も,自身が持つ %I の `name$m 属性は照会できる — %H の `index()$m ~methodを利用しても, %I↗ には~accessできなくなるが。 ◎ How is this observable? ◎ Although script cannot access an index by using the index() method on an IDBObjectStore instance after the transaction is aborted, it can still have references to IDBIndex instances where the name property can be queried.
注記: [ %接続 を表現する `IDBDatabase!I ~instance ]の `name$m は、中止された`昇格~tx$が新たな`~db$を作成していたとしても,`値を保持し続ける$。 ◎ The name property of the IDBDatabase instance is not modified, even if the aborted upgrade transaction was creating a new database.
5.9. `success^et ~eventの発火-法
`要請$ %要請 に向けて `~success~eventを発火する@ 手続きは、次で与えられる: ◎ To fire a success event at a request, the implementation must run these steps:
- %~event ~LET `Event$I を用いて`~eventを作成-$した結果 ◎ Let event be the result of creating an event using Event.
- %~event の各種~属性を次のように初期化する ⇒# `type$m ~SET `success^l, `bubbles$m ~SET ~F, `cancelable$m ~SET ~F ◎ • Set event’s type attribute to "success". • Set event’s bubbles and cancelable attributes to false.
- %~tx ~LET %要請 の`設置先~tx$ ◎ Let transaction be request’s transaction.
- %~tx の`作動中~flag$ ~SET ~ON ◎ Let legacyOutputDidListenersThrowFlag be initially unset. ◎ Set transaction’s active flag.
- `~listener投出あり^V ~LET `Dispatch$( %要請, %~event ) ◎ Dispatch event at request with legacyOutputDidListenersThrowFlag.
- %~tx の`作動中~flag$ ~SET ~OFF ◎ Unset transaction’s active flag.
- ~IF[ `~listener投出あり^V ~EQ ~ON ] ⇒ 次を入力に`~txを中止-$する ⇒ %error ~SET `AbortError$E ◎ If legacyOutputDidListenersThrowFlag is set, run the steps to abort a transaction with transaction and a newly created "AbortError" DOMException.
5.10. `error^et ~eventの発火-法
`要請$ %要請 に向けて `~error~eventを発火する@ 手続きは、次で与えられる: ◎ To fire an error event at a request, the implementation must run these steps:
- %~event ~LET `Event$I を用いて`~eventを作成-$した結果 ◎ Let event be the result of creating an event using Event.
- %~event の各種~属性を次のように初期化する ⇒# `type$m ~SET `error^l, `bubbles$m ~SET ~T, `cancelable$m ~SET ~T ◎ • Set event’s type attribute to "error". • Set event’s bubbles and cancelable attributes to true.
- %~tx ~LET %要請 の`設置先~tx$ ◎ Let transaction be request’s transaction.
- %~tx の`作動中~flag$ ~SET ~ON ◎ Let legacyOutputDidListenersThrowFlag be initially unset. ◎ Set transaction’s active flag.
- `~listener投出あり^V ~LET `Dispatch$( %要請, %~event ) ◎ Dispatch event at request with legacyOutputDidListenersThrowFlag.
- %~tx の`作動中~flag$ ~SET ~OFF ◎ Unset transaction’s active flag.
-
~IF[ `~listener投出あり^V ~EQ ~ON ]:
- 次を入力に `~txを中止-$する ⇒# %~tx ~SET %~tx, %error ~SET `AbortError$E
- ~RET
これは、[ %~event の`取消d~flag$ ~EQ ~ON ]の下でも行われる。
◎ If legacyOutputDidListenersThrowFlag is set, run the steps to abort a transaction with transaction and a newly created "AbortError" DOMException and terminate these steps. This is done even if the event’s canceled flag is not set.注記: すなわち、 `error$et ~eventの配送-時に,いずれかの~event~handlerから例外が投出されたときは:
- ~eventが `preventDefault()$m の~callにより取消されようが されまいが,~txは中止される。
- ~tx上の `error^m 属性には、要請の`~error$に代わって, `AbortError$E が利用される。
- %~tx の`作動中~flag$ ~SET ~OFF ◎ ↑
- ~IF[ %~event の`取消d~flag$ ~EQ ~OFF ] ⇒ 次を入力に `~txを中止-$する ⇒# %~tx ~SET %~tx, %error ~SET %要請 の`~error$ ◎ If the event’s canceled flag is not set, run the steps to abort a transaction using transaction and request’s error.
5.11. 値の~clone法
%値 を %宛先~Realm 内で `~clone@ するときは、次を走らせ~MUST: ◎ To make a clone of value in targetRealm, the implementation must run these steps:
- %直列形 ~LET ? `StructuredSerializeForStorage$jA( %値 ) ◎ Let serialized be ? StructuredSerializeForStorage(value).
- %~clone ~LET ? `StructuredDeserialize$jA( %直列形, %宛先~Realm ) ◎ Let clone be ? StructuredDeserialize(serialized, targetRealm).
- ~RET %~clone ◎ Return clone.
6. 各種~db演算
この節では、[ `保管庫$内の~data/`~db$内の`索引$ ]にて行われる種々の演算について述べる。 これらの演算は、要請を`非同期に実行する$手続きにより走らされる。 ◎ This section describes various operations done on the data in object stores and indexes in a database. These operations are run by the steps to asynchronously execute a request.
注記: 以下の各種 演算の手続きにおける `StructuredDeserialize$jA() からは、( ! 接頭辞で指示されるように)例外は投出されない — 演算する~dataは、 `StructuredSerializeForStorage$jA() から出力されたものに限られるので。 ◎ Invocations of StructuredDeserialize() in the operation steps below can be asserted not to throw (as indicated by the ! prefix) because they operate only on previous output of StructuredSerializeForStorage().
6.1. 保管庫における蓄積~演算
`保管庫に~recordを格納する@ 手続きは、次で与えられる:
- %保管庫: `保管庫$
- %値: 格納する~recordの`値$
- %key : 格納する~recordの`~key$(省略時は ε )
- %上書不可~flag: ~ON の場合,既存の~recordの値は上書きできない。
- %生成器 ~LET %保管庫 の`~key生成器$ ◎ ↓
- %keyPath ~LET %保管庫 の`~key~path$Os ◎ ↓
-
~IF[ %生成器 ~NEQ ε ]: ◎ If store uses a key generator, then:
-
~IF[ %key ~EQ ε ]: ◎ If key is undefined, then:
- %~key ~LET %保管庫 用の`~keyを生成-$した結果 ◎ Let key be the result of running the steps to generate a key for store.
- ~IF[ %~key ~EQ `失敗^i ] ⇒ ~RET `Error$( `ConstraintError$E ) ◎ If key is failure, then this operation failed with a "ConstraintError" DOMException. Abort this algorithm without taking any further steps.
- ~IF[ %keyPath ~NEQ ε ] ⇒ `Inject$( %値, %保管庫 の`~key~path$Os, %~key ) ◎ If store also uses in-line keys, then run the steps to inject a key into a value using a key path with value, key and store’s key path.
- ~ELSE ⇒ %~key で %保管庫 用の`~key生成器を可能なら更新する$ ◎ Otherwise, run the steps to possibly update the key generator for store with key.
-
-
~IF[ %保管庫 の`~record~list$Os内に[ `~key$ ~EQ~cmpkey %key ]を満たす`~record$がある ]
- ~IF[ %上書不可~flag ~EQ ~ON ] ⇒ ~RET `Error$( `ConstraintError$E ) ◎ If the no-overwrite flag was given to these steps and is set, and a record already exists in store with its key equal to key, then this operation failed with a "ConstraintError" DOMException. Abort this algorithm without taking any further steps.
- 次を入力に `保管庫から~recordを削除する$ ⇒# %保管庫 ~SET %保管庫, %範囲 ~SET `Only$( %key ) ◎ If a record already exists in store with its key equal to key, then remove the record from store using the steps to delete records from an object store.
- %保管庫 の`~record~list$Osに ~record{ %key : ! `StructuredSerializeForStorage$jA( %値 ) } を格納する — それに伴い,~listの~recordたちを~keyの`昇順$で整列し直すことになる。 ◎ Store a record in store containing key as its key and ! StructuredSerializeForStorage(value) as its value. The record is stored in the object store’s list of records such that the list is sorted according to the key of the records in ascending order.
-
%保管庫 に`専属する$ ~EACH( `索引$ %索引 ) に対し: ◎ For each index which reference store:
- %~key集合 ~LET `ExtractKeySet$( %値, %索引 の`~key~path$Ix, %索引 の`複entry~flag$Ix ) ◎ Let index key be the result of running the steps to extract a key from a value using a key path with value, index’s key path, and index’s multiEntry flag. ◎ If index key is an exception, or invalid, or failure, take no further actions for index, and continue these steps for the next index. ◎ An exception thrown in this step is not rethrown.
-
~IF[ %索引 の`一意~flag$Ix ~EQ ~ON ]~AND[ %索引 の`~record~list$Ix内に[ `~key$ ~IN~cmpkey %~key集合 ]を満たす`~record$はある ] ⇒ ~RET `Error$( `ConstraintError$E ) ◎ If index’s multiEntry flag is unset, or if index key is not an array key, and if index already contains a record with key equal to index key, and index has its unique flag set, then this operation failed with a "ConstraintError" DOMException. Abort this algorithm without taking any further steps. ◎ If index’s multiEntry flag is set and index key is an array key, and if index already contains a record with key equal to any of the subkeys of index key, and index has its unique flag set, then this operation failed with a "ConstraintError" DOMException. Abort this algorithm without taking any further steps.
【 この手続きを呼び出した要請は失敗とされ、要請を`非同期に実行する$手続きに従って,ここまでの改変は復帰されることになる。 したがって、索引たちを反復する順序も,結果には影響しない。 】
-
%~key集合 内の ~EACH( %索引~key ) に対し ⇒ %索引 の`~record~list$Ix内に 新たな~record{ %索引~key : %key } を格納する — それに伴い、~record~listは 先ず~keyの`昇順$に整列した上で,~keyが等しい~recordたちを値の`昇順$に整列することになる。 ◎ If index’s multiEntry flag is unset, or if index key is not an array key then store a record in index containing index key as its key and key as its value. The record is stored in index’s list of records such that the list is sorted primarily on the records keys, and secondarily on the records values, in ascending order. ◎ If index’s multiEntry flag is set and index key is an array key, then for each subkey of the subkeys of index key store a record in index containing subkey as its key and key as its value. The records are stored in index’s list of records such that the list is sorted primarily on the records keys, and secondarily on the records values, in ascending order.
注記: %~key集合 が空でも妥当である — その場合、索引に追加される~recordはない。 ◎ It is valid for there to be no subkeys. In this case no records are added to the index. ◎ Even if any member of subkeys is itself an array key, the member is used directly as the key for the index record. Nested array keys are not flattened or "unpacked" to produce multiple rows; only the outer-most array key is.
- ~RET %key ◎ Return key.
6.2〜3. 保管庫/索引から検索取得する演算
【 この訳では、原文の 6.2, 6.3 節の各種~演算を,(下の %取得演算 の)~parameter化により まとめて定義する。 】【 入力として下に与えられる %取得演算 には `StructuredDeserialize$jA() を孕むものもあるが、上位節の冒頭に記されたように,その演算から例外が投出されることはない。 】
`範囲に入る最初の~entryを検索取得する@ 手続きは、次で与えられる: ◎ The steps to retrieve a (value|referenced value) from an (object store|index) with (store|index) and range are as follows:
- %対象: `保管庫$/`索引$
- %範囲: `~key範囲$
- %取得演算: `~record$から対応する何かを取得する演算
- %~record ~LET %対象 の~record~list内の[ `~key$ ~IN~cmpkey %範囲 ]を満たす`~record$のうち,最初のもの ◎ Let record be the first record in (store|index)’s list of records whose key is in range, if any.
- ~RET[ %~record ~EQ ε ならば ε / ~ELSE_ %取得演算( %~record ) ] ◎ If record was not found, return undefined. ◎ ( Let (serialized|value) be of record’s (referenced value|value). Return ! StructuredDeserialize(value, targetRealm). )|( Return the result of running the steps to convert a key to a value with record’s (key|value). )
`範囲に入る~entryたちを検索取得する@ 手続きは、次で与えられる: ◎ The steps to retrieve multiple (values|keys|referenced values) from an (object store|index) with (store|index), range and optional count are as follows:
- %対象: `保管庫$ / `索引$
- %範囲: `~key範囲$
- %取得演算: `~record$から対応する何かを取得する演算
- %count: 取り出す最大の個数(省略時は ε )
- %~record~list ~LET %対象 の~record~list内の[ `~key$ ~IN %範囲 ]を満たす`~record$のうち,[ %count ~IN { ε, 0 } ならば すべての~record / ~ELSE_ 最初から %count 個までの~record ]からなる~list ◎ If count is not given or is 0 (zero), let count be infinity. ◎ Let records be a list containing the first count records in (store|index)’s list of records whose key is in range.
- %~list ~LET 新たな空~list ◎ Let list be an empty list.
- %~record~list 内の ~EACH( %~record ) に対し ⇒ %~list に %取得演算( %~record ) を付加する ◎ For each record in records: ( • Let serialized be record’s (referenced value|value). • Let entry be ! StructuredDeserialize(serialized, targetRealm). )|( • Let entry be the result of running the steps to convert a key to a value with record’s (key|value)). ) • Append entry to list.
- ~RET %~list を `~SeqAny$ 型~値に変換した結果 ◎ Return list converted to a sequence<any>.
6.2 Object Store Retrieval Operations
The steps to retrieve a value from an object store with targetRealm, store and range are as follows: • Let record be the first record in store’s list of records whose key is in range, if any. • If record was not found, return undefined. • Let serialized be of record’s value. • Return ! StructuredDeserialize(serialized, targetRealm).
The steps to retrieve multiple values from an object store with targetRealm, store, range and optional count are as follows: • If count is not given or is 0 (zero), let count be infinity. • Let records be a list containing the first count records in store’s list of records whose key is in range. • Let list be an empty list. • For each record in records: •• Let serialized be record’s value. •• Let entry be ! StructuredDeserialize(serialized, targetRealm). •• Append entry to list. • Return list converted to a sequence<any>.
The steps to retrieve a key from an object store with store and range are as follows: • Let record be the first record in store’s list of records whose key is in range, if any. • If record was not found, return undefined. • Return the result of running the steps to convert a key to a value with record’s key.
The steps to retrieve multiple keys from an object store with store, range and optional count are as follows: • If count is not given or is 0 (zero), let count be infinity. • Let records be a list containing the first count records in store’s list of records whose key is in range. • Let list be an empty list. • For each record in records: •• Let entry be the result of running the steps to convert a key to a value with record’s key. •• Append entry to list. • Return list converted to a sequence<any>.
6.3. Index Retrieval Operations
The steps to retrieve a referenced value from an index with targetRealm, index and range are as follows. • Let record be the first record in index’s list of records whose key is in range, if any. • If record was not found, return undefined. • Let serialized be record’s referenced value. • Return ! StructuredDeserialize(serialized, targetRealm).
The steps to retrieve multiple referenced values from an index with targetRealm, index, range and optional count are as follows: • If count is not given or is 0 (zero), let count be infinity. • Let records be a list containing the first count records in index’s list of records whose key is in range. • Let list be an empty list. • For each record in records: •• Let serialized be record’s referenced value. •• Let entry be ! StructuredDeserialize(serialized, targetRealm). •• Append entry to list. • Return list converted to a sequence<any>.
The values of an record in an index are the keys of records in the referenced object store.
The steps to retrieve a value from an index with index and range are as follows. • Let record be the first record in index’s list of records whose key is in range, if any. • If record was not found, return undefined. • Return the of running the steps to convert a key to a value with record’s value.
The steps to retrieve multiple values from an index with index, range and optional count are as follows: • If count is not given or is 0 (zero), let count be infinity. • Let records be a list containing the first count records in index’s list of records whose key is in range. • Let list be an empty list. • For each record in records: •• Let entry be the result of running the steps to convert a key to a value with record’s value. •• Append entry to list. • Return list converted to a sequence<any>.
6.4. 保管庫から~recordを削除する演算
`保管庫から~recordを削除する@ 手続きは、次で与えられる:
- %保管庫: `保管庫$
- %範囲: `~key範囲$
- %保管庫 の`~record~list$Osから,次を満たす`~record$をすべて除去する ⇒ `~key$ ~IN~cmpkey %範囲 ◎ Remove all records, if any, from store’s list of records with key in range.
- %保管庫 に`専属する$ ~EACH( `索引$ ) に対し ⇒ `索引$の`~record~list$Ixから,次を満たす`~record$をすべて除去する ⇒ `値$ ~IN~cmpkey %範囲 ◎ For each index which references store, remove every record from index’s list of records whose value is in range, if any such records exist.
- ~RET ε ◎ Return undefined.
6.5. 範囲に入る~recordを数える演算
`範囲に入る~recordを数える@ 手続きは、次で与えられる:
- %source: `保管庫$または`索引$
- %範囲: `~key範囲$
- ~RET %source の~record~list内の,次を満たす`~record$の総数 ⇒ `~key$ ~IN~cmpkey %範囲 ◎ Let count be the number of records, if any, in source’s list of records with key in range. ◎ Return count.
6.6. 保管庫の中を消去する演算
`保管庫の中を消去する@ 手続きは、次で与えられる:
- %保管庫: `保管庫$
- %保管庫 からすべての`~record$を除去する ◎ Remove all records from store.
- %保管庫 に`専属する$ ~EACH( `索引$ ) に対し ⇒ `索引$からすべての`~record$を除去する ◎ In all indexes which reference store, remove all records.
- ~RET ε ◎ Return undefined.
6.7. ~cursorを反復する演算
`~cursorを反復-@ する手続きは、次で与えられる:
- %cursor: `~cursor$
- %宛先~Realm:`~Realm$
- %key : 移動先の`~key$(省略時は ε )
- %主key : 保管庫における移動先の`~key$(省略時は ε )
- %count : 反復する回数(省略時は ε )
- %source ~LET %cursor の`~source$Cs↗ ◎ Let source be cursor’s source.
- %方向 ~LET %cursor の`方向$Cs ◎ Let direction be cursor’s direction.
- ~Assert: [ %主key ~EQ ε ]~OR[[ %source は`索引$である ]~AND[ %方向 ~IN { `next^l, `prev^l } ]] ◎ Assert: if primaryKey is given, source is an index and direction is "next" or "prev".
-
%~record~list ~LET %source 内の すべての~recordからなる~list ◎ Let records be the list of records in source.
注記: %~record~list は常に`~key$の昇順で整列される。 %source が`索引$である場合、それに加えて,同じ`~key$を持つ~recordたちは,それらの`値$(すなわち, ~recordの`参照先~record$の`~key$)の`昇順$でも整列される。 ◎ records is always sorted in ascending key order. In the case of source being an index, records is secondarily sorted in ascending value order (where the value in an index is the key of the record in the referenced object store).
- %範囲 ~LET %cursor の`範囲$Cs ◎ Let range be cursor’s range.
- %位置 ~LET %cursor の`位置$Cs ◎ Let position be cursor’s position.
- %保管庫~位置 ~LET %cursor の`保管庫~位置$Cs ◎ Let object store position be cursor’s object store position.
- ~IF[ %count ~EQ ε ] ⇒ %count ~SET 1 ◎ If count is not given, let count be 1.
-
%~record~list から,以下に従って一つの~recordに絞り込む:
- %~record~list から[ `~key$ ~NIN~cmpkey %範囲 ]を満たす すべての~recordを取り除く
-
~IF[
%位置 ~NEQ ε
]:
-
~IF[ %source は`保管庫$である ]~OR[ %方向 ~IN { `nextunique^l, `prevunique^l} ] ⇒ %~record~list から[ %方向 に応じて,次で与えられる条件 ]を満たす すべての~recordを取り除く:
- `next^l
- `nextunique^l
- `~key$ ~LTE~cmpkey %位置
- `prev^l
- `prevunique^l
- `~key$ ~GTE~cmpkey %位置
-
~ELSE ⇒ %~record~list から[ %方向 に応じて,次で与えられる条件 ]を満たす すべての~recordを取り除く:
- `next^l
- ( `~key$, `値$ ) ~LTE~cmpkey ( %位置, %保管庫~位置 )
- `prev^l
- ( `~key$, `値$ ) ~GTE~cmpkey ( %位置, %保管庫~位置 )
-
~IF[ %key ~NEQ ε ]
-
~IF[ %主key ~EQ ε ] ⇒ %~record~list から[ %方向 に応じて,次で与えられる条件 ]を満たす すべての~recordを取り除く:
- `next^l
- `nextunique^l
- `~key$ ~LT~cmpkey %key
- `prev^l
- `prevunique^l
- `~key$ ~GT~cmpkey %key
-
~ELSE ⇒ %~record~list から[ %方向 に応じて,次で与えられる条件 ]を満たす すべての~recordを取り除く:
- `next^l
- ( `~key$, `値$ ) ~LT~cmpkey ( %key, %主key )
- `prev^l
- ( `~key$, `値$ ) ~GT~cmpkey ( %key, %主key )
-
-
- ~IF[ %方向 ~IN { `nextunique^l, `prevunique^l } ] ⇒ %~record~list 内の ~EACH( ~keyが重複している一群の~record ) に対し ⇒ それらのうち,最初のものを除くすべての~recordを %~record~list から取り除く
-
%record ~LET %方向 に応じて,次で与えられる~record:
- `next^l
- `nextunique^l
- %~record~list 内の最初から %count 個目の~record
- `prev^l
- `prevunique^l
- %~record~list 内の最後から %count 個目の~record
-
~IF[ %record ~EQ ε ]:
- %cursor の`~key$Cs ~SET ε
- ~IF[ %source は`索引$である ] ⇒ %cursor の`保管庫~位置$Cs ~SET ε
- ~IF[ %cursor の`~key~only~flag$Cs ~EQ ~OFF ] ⇒ %cursor の`値$Cs ~SET ε
- ~RET ~NULL
While count is greater than 0:
-
Switch on direction:
- "next"
-
Let found record be the first record in records which satisfy all of the following requirements:
- If key is defined, the record’s key is greater than or equal to key.
- If primaryKey is defined, the record’s key is equal to key and the record’s value is greater than or equal to primaryKey, or the record’s key is greater than key.
- If position is defined, and source is an object store, the record’s key is greater than position.
- If position is defined, and source is an index, the record’s key is equal to position and the record’s value is greater than object store position or the record’s key is greater than position.
- The record’s key is in range.
- "nextunique"
-
◎
Let found record be the first record in records which satisfy all of the following requirements:
- If key is defined, the record’s key is greater than or equal to key.
- If position is defined, the record’s key is greater than position.
- The record’s key is in range.
- "prev"
-
Let found record be the last record in records which satisfy all of the following requirements:
- If key is defined, the record’s key is less than or equal to key.
- If primaryKey is defined, the record’s key is equal to key and the record’s value is less than or equal to primaryKey, or the record’s key is less than key.
- If position is defined, and source is an object store, the record’s key is less than position.
- If position is defined, and source is an index, the record’s key is equal to position and the record’s value is less than object store position or the record’s key is less than position.
- The record’s key is in range.
- "prevunique"
-
Let temp record be the last record in records which satisfy all of the following requirements:
- If key is defined, the record’s key is less than or equal to key.
- If position is defined, the record’s key is less than position.
- The record’s key is in range.
If temp record is defined, let found record be the first record in records whose key is equal to temp record’s key.
Iterating with "prevunique" visits the same records that "nextunique" visits, but in reverse order.
-
If found record is not defined, then:
- Set cursor’s key to undefined.
- If source is an index, set cursor’s object store position to undefined.
- If cursor’s key only flag is unset, set cursor’s value to undefined.
- Return null.
- Let position be found record’s key.
- If source is an index, let object store position be found record’s value.
- Decrease count by 1.
- %cursor の`位置$Cs ~SET %record の`~key$ ◎ Set cursor’s position to position.
- ~IF[ %source は`索引$である ] ⇒ %cursor の`保管庫~位置$Cs ~SET %record の`値$ ◎ If source is an index, set cursor’s object store position to object store position.
- %cursor の`~key$Cs ~SET %record の`~key$ ◎ Set cursor’s key to found record’s key.
-
~IF[ %cursor の`~key~only~flag$Cs ~EQ ~OFF ]: ◎ If cursor’s key only flag is unset, then:
- ~IF[ %source は`索引$である ] ⇒ %直列形 ~LET %record の`参照先~record$の`値$ ◎ Let serialized be found record’s referenced value.
- %cursor の`値$Cs ~SET ! `StructuredDeserialize$jA( %直列形, %宛先~Realm ) ◎ Set cursor’s value to ! StructuredDeserialize(serialized, targetRealm)
- %cursor の`値取得済~flag$Cs ~SET ~ON ◎ Set cursor’s got value flag.
- ~RET %cursor ◎ Return cursor.
7. ECMAScript 言語束縛
この節では、この仕様にて定義された`~key$値を[ ECMAScript 値に変換する/その逆向きに変換する ]方法, および `~key~path$を用いて`~key$を ECMAScript 値の[ 中から抽出する/中に注入する ]方法を定義する。 この節では、 ECMAScript 言語~仕様 `ECMA-262$r の各種 型/~algo を参照し,いくつかの ~algo表記規約† を用いる。 ここで述べない変換の詳細は `WEBIDL$r にて定義される。 ◎ This section defines how key values defined in this specification are converted to and from ECMAScript values, and how they may be extracted from and injected into ECMAScript values using key paths. This section references types and algorithms and uses some algorithm conventions from the ECMAScript Language Specification. [ECMA-262] Conversions not detailed here are defined in [WEBIDL].
【† 概ね、~algo内の抽象演算( `Get^jA() など)の前に現れる記号 "?", "!" を指す。 (大雑把に言えば、 "?" は 例外が生じ得ることを表し, "!" は 例外は決して生じないことを表す)。 】
【 この節の各種~algoは、~algoが呼び出す ECMAScript 抽象演算も含め,例外を値として返す(この訳で用いている ~THROW のような,例外の自動的な伝播は伴わない)。 すなわち、 ECMAScript が~algoの定義に利用している throw の定義 に従う(言語機能としての throw 文ではなく)。 そのため、この訳では,原文の語 rethrow (例外の再~投出-)を単に ~RET 文に置換している。
所与の値が `例外である@ という句は、[ その値を表現する ECMAScript Completion Record ]の `type^sl 内部~slot が `throw^i にされている(`中途完了$である)ことを意味する。 】
7.1. 値から~keyを抽出する
抽象~演算 `ExtractKey@ ( %値, %keyPath ) は、 ( `値$, `~key~path$ ) を入力にとり,[ `~key$/~failure/~invalid/例外 ]を返す:
- %r ~LET `Evaluate$( %値, %keyPath )
- ~IF[ %r は`例外である$ ]~OR[ %r ~EQ ~failure ] ⇒ ~RET %r
- ~RET `Key1$( %r )
抽象~演算 `ExtractKeySet@ ( %値, %keyPath, %複entry~flag ) は、 ( `値$, `~key~path$, ~flag値 ) を入力にとり,`~key$の集合を返す:
- %r ~LET `Evaluate$( %値, %keyPath )
- ~IF[ %r は`例外である$ ]~OR[ %r ~EQ ~failure ] ⇒ ~RET 空~集合
- ~IF[ %複entry~flag ~EQ ~ON ]~AND[ `IsArray$jA( %r ) ] ⇒ ~RET `MultiKey$( %r )
- %key ~LET `Key1$( %r )
- ~IF[ %key は`~key$でない ] ⇒ ~RET 空~集合
- ~RET %key のみからなる集合
【 この手続きは、`保管庫に~recordを格納する$手続きに伴って 索引を拡充するときに呼び出される。】【 `ExtractKey$ と `ExtractKeySet$ は、原文では一つの~algoとして定義されたものを,この訳にて二つに分離したものである。 その方が、依存関係の見通しも良くなるので(同時に、原文による `MultiKey$ の処理の一部もこの手続きに移行させている)。 原文の `ExtractKeySet$ に該当する部分は,`配列~key$を返しているが、ここでは,単に~keyの集合を返すように変えている。 その`配列~key$は一時的にしか利用されておらず(また,実際に重複もなく順序も有意でない)、そうした方が,この手続きを利用している箇所の記述も簡明になるので。 】
抽象~演算 `Evaluate@ ( %値, %keyPath ) は、 ( `値$, `~key~path$ ) を入力にとり,[ ECMAScript 値/~failure/例外 ]を返す:
【 返り値~failureは、 %値 の中に %keyPath が指す部位が存在しないことを表す。 】
◎ The steps to evaluate a key path on a value with value and keyPath are as follows. The result of these steps is an ECMAScript value or failure, or the steps may throw an exception.-
~IF[ %keyPath は文字列の~listである ]: ◎ If keyPath is a list of strings, then:
- %結果 ~LET 式 `[]^js で作成されるものと同じ,新たな `Array$js ~obj ◎ Let result be a new Array object created as if by the expression [].
- %i ~LET 0 ◎ Let i be 0.
-
%keyPath 内の ~EACH( %item ) に対し: ◎ For each item in keyPath:
- %key ~LET `Evaluate$( %値, %item )† ◎ Let key be the result of recursively running the steps to evaluate a key path on a value using item as keyPath and value as value.
- ~Assert: %key は`中途完了$でない ◎ Assert: key is not an abrupt completion.
- ~IF[ %key ~EQ ~failure ] ⇒ ~RET ~failure ◎ If key is failure, abort the overall algorithm and return failure.
- %p ~LET ! `ToString$jA( %i ) ◎ Let p be ! ToString(i).
- %status ~LET `CreateDataProperty$jA(%result, %p, %key) ◎ Let status be CreateDataProperty(result, p, key).
- ~Assert: %status ~EQ ~T ◎ Assert: status is true.
- %i ~INCBY 1 ◎ Increase i by 1.
- ~RET %結果 ◎ Return result.
注記(†): これは、一階層のみ “再帰する” — `~key~path$ 連列は入子にできないので。 ◎ This will only ever "recurse" one level since key path sequences can’t ever be nested.
- ~IF[ %keyPath ~EQ 空~文字列 ] ⇒ ~RET %値 ◎ If keyPath is the empty string, return value and skip the remaining steps.
- %識別子~list ~LET `区切子で厳密に分割する$( %keyPath, ~PERIOD ) ◎ Let identifiers be the result of strictly splitting keyPath on U+002E FULL STOP characters (.).
-
%識別子~list 内の ~EACH( %識別子 ) に対し ◎ For each identifier in identifiers, jump to the appropriate step below:
-
~IF[ 下の表内に ( %値 が満たす条件, %識別子 ) に該当する行がある ] ⇒ %値 ~LET 同じ行の “結果” の列に与える値
%値 が満たす条件 %識別子 結果 `Type$jA( %値 ) ~EQ `String$js `length^l %値 内の要素~数に等しい `Number$js 値 If Type(value) is String, and identifier is "length" • Let value be a Number equal to the number of elements in value. `Array$js である `length^l ! `ToLength$jA( ! `Get$jA( %値, `length^l ) ) If value is an Array and identifier is "length" • Let value be ! ToLength(! Get(value, "length")). `Blob$I である `size^l %値 の `size$mF に等しい `Number$js 値 If value is a Blob and identifier is "size" • Let value be a Number equal to value’s size. `Blob$I である `type^l %値 の `type$mF に等しい `String$js 値 If value is a Blob and identifier is "type" • Let value be a String equal to value’s type. `File$I である `name^l %値 の `name$mF に等しい `String$js 値 If value is a File and identifier is "name" • Let value be a String equal to value’s name. `File$I である `lastModified^l %値 の `lastModified$mF に等しい `Number$js 値 If value is a File and identifier is "lastModified" • Let value be a Number equal to value’s lastModified. `File$I である `lastModifiedDate^l `DateValue^sl 内部~slotが %値 の `lastModified$mF に等しくされた,新たな `Date$js ~obj If value is a File and identifier is "lastModifiedDate" • Let value be a new Date object with [[DateValue]] internal slot equal to value’s lastModified. 【 `File^I であるならば `Blob^I でもあることに注意。 】
-
~ELSE: ◎ Otherwise
- ~IF[ `Type$jA( %値 ) ~NEQ `Object$js ] ⇒ ~RET ~failure ◎ If Type(value) is not Object, return failure.
- %hop ~LET ! `HasOwnProperty$jA( %値, %識別子 ) ◎ Let hop be ! HasOwnProperty(value, identifier).
- ~IF[ %hop ~EQ `false^js ] ⇒ ~RET ~failure ◎ If hop is false, return failure.
- %値 ~LET ! `Get$jA( %値, %識別子 ) ◎ Let value be ! Get(value, identifier).
- ~IF[ %値 ~EQ `undefined^js ] ⇒ ~RET ~failure ◎ If value is undefined, return failure.
-
- ~Assert: %値 は`中途完了$でない ◎ Assert: value is not an abrupt completion.
- ~RET %値 ◎ Return value.
注記: この~algoが適用される値は, `StructuredDeserialize$jA からの出力であり, “自前の” ~propのみに~accessするので、上の手続きにおける ~Assert は満たされる。 ◎ Assertions can be made in the above steps because this algorithm is only applied to values that are the output of StructuredDeserialize and only access "own" properties.
7.2. 値に~keyを注入する
この節で利用される`~key~path$は、決して連列( ~SeqDS )ではなく,常に文字列である — `~key生成器$を持ちつつ,`~key~path$Osは連列にされた`保管庫$は作成し得ないので。 ◎ The key paths used in this section are always strings and never sequences, since it is not possible to create a object store which has a key generator and also has a key path that is a sequence.
`~keyを値の中に注入できるか検査する@ ときは、所与の ( %値, %keyPath ) に対し[ ~T / ~F ]を返す: ◎ The steps to check that a key could be injected into a value are as follows. The algorithm takes a value and a keyPath, and outputs true or false.
- %識別子~list ~LET `区切子で厳密に分割する$( %keyPath, ~PERIOD ) ◎ Let identifiers be the result of strictly splitting keyPath on U+002E FULL STOP characters (.).
- ~Assert: %識別子~list は空でない ◎ Assert: identifiers is not empty.
-
%識別子~list 内の最後の要素を除く ~EACH( %識別子 ) に対し: ◎ Remove the last member of identifiers. ◎ For each remaining identifier in identifiers, if any:
- ~IF[ %値 は[ `Object$js, `Array$js ]のいずれでもない ] ⇒ ~RET ~F ◎ If value is not an Object or an Array, return false.
- %hop ~LET ! `HasOwnProperty$jA( %値, %識別子 ) ◎ Let hop be ! HasOwnProperty(value, identifier).
- ~IF[ %hop ~EQ `false^js ] ⇒ ~RET ~T ◎ If hop is false, return true.
- %値 ~LET ! `Get$jA( %値, %識別子 ) ◎ Let value be ! Get(value, identifier).
- ~RET[ %値 は[ `Object$js, `Array$js ]のいずれかならば ~T / ~ELSE_ ~F ] ◎ Return true if value is an Object or an Array, or false otherwise.
この~algoが適用される値は, `StructuredDeserialize$jA からの出力なので、上の手続きにおける ~Assert は満たされる。 ◎ Assertions can be made in the above steps because this algorithm is only applied to values that are the output of StructuredDeserialize.
抽象~演算 `Inject@ ( %値, %keyPath, %key ) は、 ( `値$, `~key~path$Os, `~key$ ) を入力にとり,[ 例外 / ε ]を返す: ◎ The steps to inject a key into a value using a key path are as follows. The algorithm takes a value, a key and a keyPath.
- %識別子~list ~LET `区切子で厳密に分割する$( %keyPath, ~PERIOD ) ◎ Let identifiers be the result of strictly splitting keyPath on U+002E FULL STOP characters (.).
- ~Assert: %識別子~list は空でない ◎ Assert: identifiers is not empty.
- %last ~LET %識別子~list の最後の要素 ◎ Let last be the last member of identifiers and remove it from the list.
-
%識別子~list 内の最後の要素を除く ~EACH( %識別子 ) に対し: ◎ For each remaining identifier in identifiers:
- ~Assert %値 は[ `Object$js, `Array$js ]のいずれかである ◎ Assert: value is an Object or an Array.
- %hop ~LET ! `HasOwnProperty$jA( %値, %識別子 ) ◎ Let hop be ! HasOwnProperty(value, identifier).
-
~IF[ %hop ~EQ `false^js ]: ◎ If hop is false, then:
- %o ~LET 式 `({})^js で作成されるものと同じ,新たな `Object$js ◎ Let o be a new Object created as if by the expression ({}).
- %status ~LET `CreateDataProperty$jA( %値, %識別子, %o ) ◎ Let status be CreateDataProperty(value, identifier, o).
- ~Assert: %status ~EQ `true^js ◎ Assert: status is true.
- %値 ~LET ! `Get$jA( %値, %識別子 ) ◎ Let value be ! Get(value, identifier).
- ~Assert: %値 は `Object$js または `Array$js である ◎ Assert: value is an Object or an Array.
- %keyValue ~LET `Value1$( %key ) ◎ Let keyValue be the result of running the steps to convert a key to a value with key.
- %status ~LET `CreateDataProperty$jA( %値, %last, %keyValue ) ◎ Let status be CreateDataProperty(value, last, keyValue).
- ~Assert: %status ~EQ `true^js ◎ Assert: status is true.
注記: この~algoが適用される値は、 `StructuredDeserialize$jA からの出力であり,`~keyを値の中に注入できるか検査-$した後なので、上の手続きにおける ~Assert は満たされる。 ◎ Assertions can be made in the above steps because this algorithm is only applied to values that are the output of StructuredDeserialize, and the steps to check that a key could be injected into a value have been run.
7.3. ~keyから値へ変換する
抽象~演算 `Value1@ ( %key ) は、 ( `~key$ ) を入力にとり, ECMAScript 値を返す: ◎ The steps to convert a key to a value are as follows. These steps take one argument, key, and return an ECMAScript value.
- %値 ~LET %key の`値$key ◎ Let type be key’s type. ◎ Let value be key’s value.
-
%key の`種別$keyに応じて: ◎ Switch on type:
- `number$i
- ~RET %値 に等しい ECMAScript `Number$js 値 ◎ Return an ECMAScript Number value equal to value
- `string$i
- ~RET %値 に等しい ECMAScript `String$js 値 ◎ Return an ECMAScript String value equal to value
- `date$i
-
- %date ~LET ( %値 ) を引数に ECMAScript `Date$js 構築子を実行した結果 ◎ Let date be the result of executing the ECMAScript Date constructor with the single argument value.
- ~Assert: %date は`中途完了$でない ◎ Assert: date is not an abrupt completion.
- ~RET %date ◎ Return date.
- `binary$i
-
- %buffer ~LET ( %値 の長さ ) を引数に ECMAScript `ArrayBuffer$js 構築子を実行した結果 ◎ Let len be the length of value. ◎ Let buffer be the result of executing the ECMAScript ArrayBuffer constructor with len.
- ~Assert: %buffer は`中途完了$でない ◎ Assert: buffer is not an abrupt completion.
- %buffer の `ArrayBufferData^sl 内部~slotの~entryたち ~SET %値 の~entryたち ◎ Set the entries in buffer’s [[ArrayBufferData]] internal slot to the entries in value.
- ~RET %buffer ◎ Return buffer.
- `array$i
-
- %array ~LET 引数なしで ECMAScript `Array$js 構築子を実行した結果 ◎ Let array be the result of executing the ECMAScript Array constructor with no arguments.
- ~Assert: %array は`中途完了$でない ◎ Assert: array is not an abrupt completion.
-
~EACH( 整数 %index ~IN { 0 〜 %値 の長さ ~MINUS 1 } ) に対し,昇順に: ◎ Let len be the length of value. ◎ Let index be 0. ◎ While index is less than len:
- %entry ~LET `Value1$( %値 の中の %index 番の~entry ) ◎ Let entry be the result of running the steps to convert a key to a value with the indexth entry of value as input.
- %status ~LET `CreateDataProperty$jA( %array, %index, %entry ) ◎ Let status be CreateDataProperty(array, index, entry).
- ~Assert: %status ~EQ ~T ◎ Assert: status is true. ◎ Increase index by 1.
- ~RET %array ◎ Return array.
7.4. 値から~keyへ変換する
抽象~演算 `Key1@ ( %input, %seen ) は、 ( ECMAScript 値, 集合 ) を入力にとり,[ `~key$/~invalid/例外 ]を返す: ◎ The steps to convert a value to a key are as follows. These steps take two arguments, an ECMAScript value input, and an optional set seen. The result of these steps is a key or invalid, or the steps may throw an exception.
【 %seen は %input 配列が自身を入子にしているかどうか検査するために利用される。 】
- ~IF[ %seen ~EQ ε ] ⇒ %seen ~SET 新たな空~集合 ◎ If seen was not given, let seen be a new empty set.
- ~IF[ %input ~IN %seen ] ⇒ ~RET ~invalid ◎ If input is in seen return invalid.
-
~IF[ `Type$jA( %input ) ~EQ `Number$js ]: ◎ Jump to the appropriate step below: ◎ If Type(input) is Number
- ~IF[ %input ~EQ `NaN^js ] ⇒ ~RET ~invalid ◎ If input is NaN then return invalid.
- ~RET 次の様にされた新たな`~key$ ⇒# `種別$key ~SET `number$i, `値$key ~SET %input ◎ Otherwise, return a new key with type number and value input.
-
~ELIF[ %input は `Date$js ~objである( `DateValue^sl 内部~slotを持つ) ]: ◎ If input is a Date (has a [[DateValue]] internal slot)
- %ms ~LET %input の `DateValue^sl 内部~slotの値 ◎ Let ms be the value of input’s [[DateValue]] internal slot.
- ~IF[ %ms ~EQ `NaN^js ] ⇒ ~RET ~invalid ◎ If ms is NaN then return invalid.
- ~RET 次の様にされた新たな`~key$ ⇒# `種別$key ~SET `date$i, `値$key ~SET %ms ◎ Otherwise, return a new key with type date and value ms.
-
~ELIF[ `Type$jA( %input ) ~EQ `String$js ] ⇒ ~RET 次の様にされた新たな`~key$ ⇒# `種別$key ~SET `string$i, `値$key ~SET %input ◎ If Type(input) is String • Return a new key with type string and value input.
-
~ELIF[ %input は`~buffer~source型$である ] ◎ If input is a buffer source type
- %octets ~LET %input から`~buffer~sourceに保持されている~byte列の複製を取得-$した結果 ◎ Let octets be the result of running the steps to get a copy of the bytes held by the buffer source input. Rethrow any exceptions.
- ~IF[ %octets は`例外である$ ] ⇒ ~RET %octets ◎ ↑
- ~RET 次の様にされた新たな`~key$ ⇒# `種別$key ~SET `binary$i, `値$key ~SET %octets ◎ Return a new key with type binary and value octets.
-
~ELIF[ `IsArray$jA( %input ) ]: ◎ If IsArray(input)
- %len ~LET ? `ToLength$jA( ? `Get$jA( %input, `length^l)) ◎ Let len be ? ToLength( ? Get(input, "length")).
- %input を %seen に追加する ◎ Add input to seen.
- %keys ~LET 新たな空~list ◎ Let keys be a new empty list.
-
~EACH( 整数 %index ~IN { 0 〜 %len ~MINUS 1 } ) に対し,昇順に: ◎ Let index be 0. ◎ While index is less than len:
- %hop ~LET ? `HasOwnProperty$jA( %input, %index ) ◎ Let hop be ? HasOwnProperty(input, index).
- ~IF[ %hop ~EQ `false^js ] ⇒ ~RET ~invalid ◎ If hop is false, return invalid.
- %entry ~LET ? `Get$jA( %input, %index ) ◎ Let entry be ? Get(input, index).
- %key ~LET `Key1$( %entry, %seen ) ◎ Let key be the result of running the steps to convert a value to a key with arguments entry and seen.
- ~IF[ %key は`例外である$ ]~OR[ %key ~EQ ~invalid ] ⇒ ~RET %key ◎ ReturnIfAbrupt(key). ◎ If key is invalid abort these steps and return invalid.
- %keys に %key を付加する ◎ Append key to keys. ◎ Increase index by 1.
- ~RET 次の様にされた新たな`~key$ ⇒# `種別$key ~SET `array$i, `値$key ~SET %keys ◎ Return a new array key with value keys.
- ~RET ~invalid ◎ Otherwise • Return invalid.
抽象~演算 `MultiKey@ ( %array ) は、 ( ECMAScript `Array$js 値 ) を入力にとり,`~key$の集合を返す: ◎ The steps to convert a value to a multiEntry key are as follows. These steps take one argument, an ECMAScript value input. The result of these steps is a key or invalid, or the steps may throw an exception. ◎ If IsArray(input), then:
- %len ~LET ? `ToLength$jA( ? `Get$jA( %array, `length^l)) ◎ Let len be ? ToLength( ? Get(input, "length")).
- %seen ~LET %array のみからなる新たな集合 ◎ Let seen be a new set containing only input.
- %key集合 ~LET 新たな空~集合 ◎ Let keys be a new empty set.
- %index ~LET 0 ◎ Let index be 0.
-
~WHILE ( %index ~LT %len ) : ◎ While index is less than len:
- %entry ~LET `Get$jA( %array, %index ) ◎ Let entry be Get(input, index).
-
~IF[ %entry は`中途完了$でない ]: ◎ If entry is not an abrupt completion, then:
- %key ~LET `Key1$( %entry, %seen ) ◎ Let key be the result of running the steps to convert a value to a key with arguments entry and seen.
- ~IF[ %key は`~key$である ]~AND[ %key ~NIN~cmpkey %key集合 ] ⇒ %key を %key集合 に追加する ◎ If key is not invalid or an abrupt completion, add key to keys if there are no other members of keys equal to key.
- %index ~INCBY 1 ◎ Increase index by 1.
- ~RET %key集合 ◎ Return a new array key with value set to a list of the members of keys.
この手続きは、`~key$へ変換できない~memberは無視した上で, 重複するものを除去する。 ◎ Otherwise, return the result of running the steps to convert a value to a key with argument input. Rethrow any exceptions. ◎ These steps are similar to those to convert a value to a key but if the top-level value is an Array then members which can not be converted to keys are ignored, and duplicates are removed.
例えば配列 `[10, 20, null, 30, 20]^js は、`~key$の集合 { 10, 20, 30 } に変換される。 ◎ For example, the value [10, 20, null, 30, 20] is converted to an array key with subkeys 10, 20, 30.
8. ~privacy上の考慮点
~INFORMATIVE8.1. 利用者の追跡
第三者主体~host (あるいは、複数の~siteに配布される内容を取得する~~能力を持つ任意の~obj)は、その~client側~db内に格納された一意な識別子を利用して,複数~sessionにわたって利用者を追跡した上で,利用者の活動について~profileを築くこともできる。 利用者の本当の~~識別情報を知る~site( 例えば、認証-済み資格証明情報を要求する電子商取引~site )と組み合わされれば、どこかの圧政的団体が,純粋に匿名な~webの用法より ずっと~~正確に個々人を標的にすることも可能になる。 ◎ A third-party host (or any object capable of getting content distributed to multiple sites) could use a unique identifier stored in its client-side database to track a user across multiple sessions, building a profile of the user’s activities. In conjunction with a site that is aware of the user’s real id object (for example an e-commerce site that requires authenticated credentials), this could allow oppressive groups to target individuals with greater accuracy than in a world with purely anonymous Web usage.
利用者~追跡の~riskを軽減するために利用できる,いくつもの技法がある: ◎ There are a number of techniques that can be used to mitigate the risk of user tracking:
- 第三者主体による蓄積を阻止する。 ◎ Blocking third-party storage
- ~UAは、~db~objへの~accessを[ 閲覧~文脈の~top-level文書の~domainを出自にする~script ]に制約して~MAY — 具体例として, `iframe^e 内で稼働している他の~domainからの頁に対しては~APIへの~accessを否認するなど。 ◎ User agents may restrict access to the database objects to scripts originating at the domain of the top-level document of the browsing context, for instance denying access to the API for pages from other domains running in iframes.
- 格納された~dataを失効させる ◎ Expiring stored data
-
~UAは、格納されている~dataを、一定期間~後に自動的に削除して~MAY。 ◎ User agents may automatically delete stored data after a period of time.
これは、~siteが利用者を追跡する能を制約し得る — ~siteは、~site自身が利用者を認証する(例:購入や~serviceへのログイン時など)以外にも,利用者を複数~sessionにわたって追跡できなくする。 ◎ This can restrict the ability of a site to track a user, as the site would then only be able to track the user across multiple sessions when she authenticates with the site itself (e.g. by making a purchase or logging in to a service).
しかしながら一方で、利用者の~dataも~riskに晒す。 ◎ However, this also puts the user’s data at risk.
- 永続的~蓄積を~cookieと同様に扱う ◎ Treating persistent storage as cookies
-
~UAは、~db特色機能を HTTP ~session~cookie `COOKIES$r に強く結付けるような仕方で利用者に提示するべきである。 ◎ User agents should present the database feature to the user in a way that associates them strongly with HTTP session cookies. [COOKIES]
これは、利用者が そのような蓄積を~~健全な疑いで見ることを促すであろう。 ◎ This might encourage users to view such storage with healthy suspicion.
- ~dbへ~accessできる~siteを個別に~safe-listに入れる ◎ Site-specific safe-listing of access to databases
- ~UAは、~siteがこの仕様の特色機能を利用できるようになる前に、~dbに~accessする権限付与-を利用者に要求して~MAY。 ◎ User agents may require the user to authorize access to databases before a site can use the feature.
- 格納された~dataの生成元~追跡 ◎ Origin-tracking of stored data
-
~UAは、第三者主体 `生成元$による内容を包含している~siteが,~dataを格納させたときは、その~siteの`生成元$を記録して~MAY。 ◎ User agents may record the origins of sites that contained content from third-party origins that caused data to be stored.
その上で、この情報を,永続的に蓄積されている現在の~dataを提示するために利用するならば、 利用者は,その情報を吟味した上で 永続的~蓄積からどの部分を取り除くか~~決定を下せるようになる。 ~阻止list( “この~dataを削除して,この~domainにこれ以上~dataを格納させない” )と組合わすことで、利用者は,永続的~蓄積の利用を自身が信用する~siteのみに制約できるようになる。 ◎ If this information is then used to present the view of data currently in persistent storage, it would allow the user to make informed decisions about which parts of the persistent storage to prune. Combined with a blocklist ("delete this data and prevent this domain from ever storing data again"), the user can restrict the use of persistent storage to sites that she trusts.
- 共有~阻止list ◎ Shared blocklists
-
~UAは、利用者たちが,永続的~蓄積~domainの~阻止listを共有できるようにして~MAY。 ◎ User agents may allow users to share their persistent storage domain blocklists.
これは、~communityが~~協同して自らの~privacyを保護できるようにする。 ◎ This would allow communities to act together to protect their privacy.
これらの提言は、この~APIによる,利用者を追跡するための自明な利用については防止するが、すべてを阻止できるわけではない。 単独の~domainの中では、~siteは,~sessionの間 利用者を追跡し続けて、その情報すべてを[ ~siteが得た識別情報(名前, クレジットカード番号, 住所など) ]と一緒に第三者主体に渡すこともできる。 第三者主体が複数の~siteと協同して,そのような情報を得た場合、依然として~profileを作成し得る。 ◎ While these suggestions prevent trivial use of this API for user tracking, they do not block it altogether. Within a single domain, a site can continue to track the user during a session, and can then pass all this information to the third party along with any identifying information (names, credit card numbers, addresses) obtained by the site. If a third party cooperates with multiple sites to obtain such information, a profile can still be created.
しかしながら,利用者~追跡は、~UAとの協同が全くなくても,ある程度まで~~可能である — 具体例として,~URL内に~session識別子を利用するなど。 この技法は、差し障りない目的でも すでに共通的に利用されているが,利用者~追跡に容易に(遡及的にすら)転用できる。 しかる後,この情報は、他~siteと共有され得る — 訪問者の IP ~addressその他の,利用者~特有の~data(例: user-agent ~headerや環境設定)を利用して、別々の~sessionを,利用者~profileに~~整合的に~~統合するために。 ◎ However, user tracking is to some extent possible even with no cooperation from the user agent whatsoever, for instance by using session identifiers in URLs, a technique already commonly used for innocuous purposes but easily repurposed for user tracking (even retroactively). This information can then be shared with other sites, using visitors' IP addresses and other user-specific data (e.g. user-agent headers and configuration settings) to combine separate sessions into coherent user profiles.
8.3. ~dataの~sensitive性
~UAは、永続的に格納された~dataを,~sensitiveになり得るものと扱うべきである — この仕組み内に[ メール / 予定表 / 健康診断記録 ]その他の機密的~文書が格納されることは、ごく普通にあり得る。 ◎ User agents should treat persistently stored data as potentially sensitive; it is quite possible for e-mails, calendar appointments, health records, or other confidential documents to be stored in this mechanism.
ゆえに、~UAは、~dataを削除するときには,下層の蓄積からも即座に削除されることを確保するべきである。 ◎ To this end, user agents should ensure that when deleting data, it is promptly deleted from the underlying storage.
9. 保安~上の考慮点
9.1. DNS 偽装~攻撃
DNS 偽装~攻撃の~~可能性があるので、ある~domainに属すると主張している~hostが本当にその~domainなのかは,保証できない。 これを軽減するため、頁は TLS を利用できる。 TLS を利用している頁は、その~domainの~dbに~accessできる頁は[ TLS を利用していて, 同じ~domainを識別する証明書を持つもの ]に限られることを確保できる。 ◎ Because of the potential for DNS spoofing attacks, one cannot guarantee that a host claiming to be in a certain domain really is from that domain. To mitigate this, pages can use TLS. Pages using TLS can be sure that only pages using TLS that have certificates identifying them as being from the same domain can access their databases.
9.2. ~cross-directory攻撃
同じ~host名 — 例えば `geocities.com^c — を共有している作者たちは、同じ~dbの集合を共有する。 ◎ Different authors sharing one host name, for example users hosting content on geocities.com, all share one set of databases.
~accessを~URL~pathに基いて制約する特色機能は無い。 したがって、共有~host上の作者には、これらの特色機能を利用しないことが推奨される — 他の作者が,その~dataを読取したり上書きできるのは自明なので。 ◎ There is no feature to restrict the access by pathname. Authors on shared hosts are therefore recommended to avoid using these features, as it would be trivial for other authors to read the data and overwrite it.
注記: ~pathによる制約の特色機能が可用にされたとしても、通例の DOM ~scriptにおける保安~modelの下では,この保護を迂回して任意の~pathから~dataへ~accessすることは自明になる。 ◎ Even if a path-restriction feature was made available, the usual DOM scripting security model would make it trivial to bypass this protection and access the data from any path.
9.3. 実装にあたっての~risk
これらの永続的な蓄積~用の特色機能を実装するにあたって,主に二つの~risk — 敵対的~siteが[ 他の~domainから情報を読取する / 情報を書込して他の~domainに読取させる ]こと — がある: ◎ The two primary risks when implementing these persistent storage features are letting hostile sites read information from other domains, and letting hostile sites write information that is then read from other domains.
第三者主体~siteが,その~domainから読取されるものと~~想定されていないような~dataを読取できるようになれば、情報~漏洩になる。 例えば,ある購買~site~domainの,利用者の “欲しい物リスト” が、別の~domainにより~targeted広告に利用されたり,あるいは、文書作成~siteに格納された,利用者が作業中の機密的~文書を,競合企業~siteが覗き見ることも可能になる。 ◎ Letting third-party sites read data that is not supposed to be read from their domain causes information leakage, For example, a user’s shopping wish list on one domain could be used by another domain for targeted advertising; or a user’s work-in-progress confidential documents stored by a word-processing site could be examined by the site of a competing company.
第三者主体~siteが,他の~domainの永続的~蓄積に~dataを書込できるようになれば、情報~偽装(なりすまし)になり,同等に危険である。 例えば,敵対的~siteは、利用者の “欲しい物リスト” に~recordを追加したり、利用者の~session識別子を既知の ID に設定して,利用者の被害者~siteにおける行動を追跡するためにそれを利用することも可能になる。 ◎ Letting third-party sites write data to the persistent storage of other domains can result in information spoofing, which is equally dangerous. For example, a hostile site could add records to a user’s wish list; or a hostile site could set a user’s session identifier to a known ID that the hostile site can then use to track the user’s actions on the victim site.
したがって、この仕様に述べられる生成元~modelに厳格に従うことは、利用者の保安にとって重要である。 ◎ Thus, strictly following the origin model described in this specification is important for user security.
~file~systemにおける持続性のために[ 生成元や~dbの名前 ]を用いて~pathを構築する場合、敵対者が[ `../^l などの相対~pathを利用している他の生成元 ]から情報に~accessするのを防止するため、適切に~escapeされ~MUST。 ◎ If origins or database names are used to construct paths for persistence to a file system they must be appropriately escaped to prevent an adversary from accessing information from other origins using relative paths such as "../".
9.4. 持続性の~risk
実用的な実装は、不揮発~蓄積~媒体に~dataを持続化することになる。 ~dataは、格納-時に直列化され,検索取得-時に逆直列化されることになる — 直列化~形式の詳細は、~UAに特有になるが。 ~UAの直列化~形式は、時を経れば変更される可能性が高い。 例えば、[ 新たな~data型を取扱う/処理能を改善する ]ため,形式は更新されることもある。 したがって、この仕様の運用上の要件を充足するためには、実装は,何らかの仕方で旧~直列化~形式を取扱え~MUST。 旧~dataの不適正な取扱いは、基本的な直列化の懸念に加えて,保安~上の課題にもなり得る。 直列化された旧~dataは、[ ~versionが新しくされた~UAの下では妥当でない,形式 ]を符号化しかねない。 ◎ Practical implementations will persist data to a non-volatile storage medium. Data will be serialized when stored and deserialized when retrieved, although the details of the serialization format will be user-agent specific. User agents are likely to change their serialization format over time. For example, the format may be updated to handle new data types, or to improve performance. To satisfy the operational requirements of this specification, implementations must therefore handle older serialization formats in some way. Improper handling of older data can result in security issues. In addition to basic serialization concerns, serialized data could encode assumptions which are not valid in newer versions of the user agent.
実用的な例として、 `RegExp$js 型が挙げられる — その型の~objも `StructuredSerializeForStorage$jA 演算で直列化できる。 代表的な~UAは、入力~dataが渡され, 結果が返される方法を前提に,正規表現を~machineに~nativeな~~命令に~compileすることになる。 この内部~状態が~dbに格納された~dataの一部として直列化されていた場合、内部~表現が後で逆直列化されるときに様々な問題が生じることもある。 例えば、~dataが~codeの中へ渡される手段は変更されるかもしれない。 ~compiler出力における保安~bugは,~UAの更新~時に識別され修正できようが、直列化された内部~状態は残り続ける。 ◎ A practical example of this is the RegExp type. The StructuredSerializeForStorage operation allows serializing RegExp objects. A typical user agent will compile a regular expression into native machine instructions, with assumptions about how the input data is passed and results returned. If this internal state was serialized as part of the data stored to the database, various problems could arise when the internal representation was later deserialized. For example, the means by which data was passed into the code could have changed. Security bugs in the compiler output could have been identified and fixed in updates to the user agent, but remain in the serialized internal state.
~UAは、旧~dataを適切に識別して取扱え~MUST。 ~approachの一例としては、直列化~形式~内に~version識別子を含ませておき,旧~dataに遭遇したときは,~scriptから可視の状態から内部~状態を再~構築することが挙げられる。 ◎ User agents must identify and handle older data appropriately. One approach is to include version identifiers in the serialization format, and to reconstruct any internal state from script-visible state when older data is encountered.
10. 改訂~履歴
~INFORMATIVE以下は、この仕様の最後の発行からの変更点の要約である。 完全な改訂~履歴 / 第 1 版の改訂~履歴 / 第 2 版の改訂~履歴 ◎ The following is an informative summary of the changes since the last publication of this specification. A complete revision history can be found here. For the revision history of the first edition, see that document’s Revision History. For the revision history of the second edition, see that document’s Revision History.
- 他の仕様との統合~用に、`索引付き~db~txを片付ける$~algoは値を返すようにした。 (pull#232) ◎ The cleanup Indexed Database transactions algorithm now returns a value for integration with other specs. (PR #232)
- `WindowOrWorkerGlobalScope^I は今や mixin になったので、部分的~interface定義を更新した。 (pull#238) ◎ Updated partial interface definition since WindowOrWorkerGlobalScope is now a mixin (PR #238).
11. 謝辞
~INFORMATIVEこの仕様の第1版の元々の作者である Nikunj Mehta 氏に特に感謝する。 次の方々,並びに第1版の他の編集者たちにも。
Special thanks to Nikunj Mehta, the original author of the first edition, and Jonas Sicking, Eliot Graff, Andrei Popescu, and Jeremy Orlow, additional editors of the first edition.
この仕様の設計に強い影響力を及ぼした Garret Swart 氏に。 ◎ Garret Swart was extremely influential in the design of this specification.
この文書の作成-時に利用した 仕様~著作~tool Bikeshed を作成-/保守され,一般的な著作~法を~~助言された Tab Atkins, Jr. 氏に。 ◎ Thanks to Tab Atkins, Jr. for creating and maintaining Bikeshed, the specification authoring tool used to create this document, and for his general authoring advice.
~feedbackと提言を寄せられ,この仕様を向上させた,次の方々に特別な謝意を:
Special thanks to Chris Anderson, Pablo Castro, Victor Costan, Kristof Degrave, Domenic Denicola, Jake Drew, Ben Dilts, João Eiras, Alec Flett, Dana Florescu, David Grogan, Israel Hilerio, Jerome Hode, Kyle Huey, Philip Jägenstedt, Laxminarayan G Kamath A, Anne van Kesteren, Adam Klein, Tobie Langel, Kang-Hao Lu, Andrea Marchesini, Glenn Maynard, Ms2ger, Odin Omdal, Danillo Paiva, Olli Pettay, Addison Phillips, Simon Pieters, Anthony Ramine, Yonathan Randolph, Arun Ranganathan, Kagami Sascha Rosylight, Margo Seltzer, Maciej Stachowiak, Bevis Tseng, Ben Turner, Kyaw Tun, Hans Wennborg, Shawn Wilsher, Brett Zamir, Boris Zbarsky, Zhiqiang Zhang, and Kris Zyp, all of whose feedback and suggestions have led to improvements to this specification.