diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-10 08:37:18 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-10 08:37:18 -0500 |
commit | 65cc6eabd71b1bceccf6fd3d3d4970c2955f3784 (patch) | |
tree | 3d54e994e6b6ff762841fe4c3eb60e87130589a5 /files/zh-cn/web/api/idbkeyrange/index.html | |
parent | a065e04d529da1d847b5062a12c46d916408bf32 (diff) | |
download | translated-content-65cc6eabd71b1bceccf6fd3d3d4970c2955f3784.tar.gz translated-content-65cc6eabd71b1bceccf6fd3d3d4970c2955f3784.tar.bz2 translated-content-65cc6eabd71b1bceccf6fd3d3d4970c2955f3784.zip |
dump 2020-12-10
Diffstat (limited to 'files/zh-cn/web/api/idbkeyrange/index.html')
-rw-r--r-- | files/zh-cn/web/api/idbkeyrange/index.html | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/files/zh-cn/web/api/idbkeyrange/index.html b/files/zh-cn/web/api/idbkeyrange/index.html index 32481c3a02..af65cfbb11 100644 --- a/files/zh-cn/web/api/idbkeyrange/index.html +++ b/files/zh-cn/web/api/idbkeyrange/index.html @@ -16,10 +16,10 @@ translation_of: Web/API/IDBKeyRange <p>{{APIRef("IndexedDB")}}</p> <div> -<p>The <strong><code>IDBKeyRange</code></strong> interface of the <a href="/en/IndexedDB" title="en/IndexedDB">IndexedDB API</a> represents a continuous interval over some data type that is used for keys. Records can be retrieved from {{domxref("IDBObjectStore")}} and {{domxref("IDBIndex")}} objects using keys or a range of keys. You can limit the range using lower and upper bounds. For example, you can iterate over all values of a key in the value range A–Z.</p> +<p><a href="/en/IndexedDB" title="en/IndexedDB">IndexedDB API</a> 的<strong><code>IDBKeyRange</code></strong>接口表示一些数据类型上的键的连续间隔。可以使用一个键或某个范围的键从{{domxref("IDBObjectStore")}} 和{{domxref("IDBIndex")}} 对象中检索记录。您也可以指定键的上界和下界来限制范围。例如,您可以遍历值范围a - z中的键的所有值。</p> </div> -<p>A key range can be a single value or a range with upper and lower bounds or endpoints. If the key range has both upper and lower bounds, then it is <em>bounded</em>; if it has no bounds, it is <em>unbounded</em>. A bounded key range can either be open (the endpoints are excluded) or closed (the endpoints are included). To retrieve all keys within a certain range, you can use the following code constructs:</p> +<p>键范围可以是单个值,也可以是具有上界、下界或端点的范围。如果键范围同时有上界或下界,那么它是有界的,否则是无界的。有界键范围可以是开放的(不包含端点)或闭合的(包含了端点)。要检索一定范围内的所有键值,可以使用以下的代码结构:</p> <table class="standard-table"> <thead> @@ -66,21 +66,21 @@ translation_of: Web/API/IDBKeyRange </thead> </table> -<p>A key is in a key range if the following conditions are true:</p> +<p>如果以下条件为true,则键包含在键范围中:</p> <ul> - <li>The lower value of the key range is one of the following: + <li>键范围的下界值为以下值或符合以下条件之一时: <ul> <li><code>undefined</code></li> - <li>Less than key value</li> - <li>Equal to key value if <code>lowerOpen</code> is <code>false</code>.</li> + <li>低于正在被鉴定的键值</li> + <li>等于正在被鉴定的键值,且键范围的<code>lowerOpen属性</code>为<code>false</code>.</li> </ul> </li> - <li>The upper value of the key range is one of the following: + <li>键范围的上界值为以下值或符合以下条件之一时: <ul> <li><code>undefined</code></li> - <li>Greater than key value</li> - <li>Equal to key value if <code>upperOpen</code> is <code>false</code>.</li> + <li>高于正在被鉴定的键值</li> + <li>等于正在被鉴定的键值,且键范围的<code>upperOpen<font face="Arial, x-locale-body, sans-serif"><span style="background-color: #ffffff;">属性为</span></font></code><code>false</code>.</li> </ul> </li> </ul> @@ -91,13 +91,13 @@ translation_of: Web/API/IDBKeyRange <dl> <dt>{{domxref("IDBKeyRange.lower")}} {{readonlyInline}}</dt> - <dd>Lower bound of the key range.</dd> + <dd>键范围的下界</dd> <dt>{{domxref("IDBKeyRange.upper")}} {{readonlyInline}}</dt> - <dd>Upper bound of the key range.</dd> + <dd>键范围的上界</dd> <dt>{{domxref("IDBKeyRange.lowerOpen")}} {{readonlyInline}}</dt> - <dd>Returns false if the lower-bound value is included in the key range.</dd> + <dd>如果下界值包含在键范围内,则返回false。</dd> <dt>{{domxref("IDBKeyRange.upperOpen")}} {{readonlyInline}}</dt> - <dd>Returns false if the upper-bound value is included in the key range.</dd> + <dd>如果上界值包含在键范围内,则返回false。</dd> </dl> <h2 id="Methods">Methods</h2> @@ -106,31 +106,31 @@ translation_of: Web/API/IDBKeyRange <dl> <dt>{{domxref("IDBKeyRange.bound()")}}</dt> - <dd>Creates a new key range with upper and lower bounds.</dd> + <dd>指定上界和下界来创建一个新的键范围</dd> <dt>{{domxref("IDBKeyRange.only()")}}</dt> - <dd>Creates a new key range containing a single value.</dd> + <dd>指定单个键值来创建一个新的键范围</dd> <dt>{{domxref("IDBKeyRange.lowerBound()")}}</dt> - <dd>Creates a new key range with only a lower bound.</dd> + <dd>指定结果集的下界来创建一个新的键范围</dd> <dt>{{domxref("IDBKeyRange.upperBound()")}}</dt> - <dd>Creates a new upper-bound key range.</dd> + <dd>指定结果集的上界来创建一个新的键范围</dd> </dl> <h3 id="Instance_methods">Instance methods</h3> <dl> <dt>{{domxref("IDBKeyRange.includes()")}}</dt> - <dd>Returns a boolean indicating whether a specified key is inside the key range.</dd> + <dd>返回一个布尔值来表示指定的键是否在键范围内。</dd> </dl> <h2 id="Examples">Examples</h2> -<p>The following example illustrates how you'd use a key range. Here we declare a <code>keyRangeValue</code> as a range between values of "A" and "F". We open a transaction (using {{domxref("IDBTransaction")}}) and an object store, and open a Cursor with {{domxref("IDBObjectStore.openCursor")}}, declaring <code>keyRangeValue</code> as its optional key range value. This means that the cursor will only retrieve records with keys inside that range. This range includes the values "A" and "F", as we haven't declared that they should be open bounds. If we used <span style="background-color: #fafbfc; font-family: consolas,monaco,andale mono,monospace; font-size: 1rem; line-height: 19px; white-space: pre;">IDBKeyRange.bound("A", "F", true, true);</span>, then the range would not include "A" and "F", only the values between them.</p> +<p>以下示例用以说明该如果使用键范围。在此我们将 <code>keyRangeValue</code> 声明为A~F之间的范围。我们打开一个事务 (使用 {{domxref("IDBTransaction")}}) 和一个对象存储, 并用 {{domxref("IDBObjectStore.openCursor")}}打开一个游标,其中<code>keyRangeValue</code>是一个可选的键范围值,指定之后游标将只检索键在该范围内的记录。这里的键范围包括了“A”和“F”,因为我们还没声明键范围为开放边界。如果我们使用 <span style="background-color: #fafbfc; font-family: consolas,monaco,andale mono,monospace; font-size: 1rem; line-height: 19px; white-space: pre;"><code>IDBKeyRange.bound("A", "F", true, true);</code>,那么这个键范围将不包括</span>“A”和“F”,只包含它们之间的值。</p> <div class="note"> <p><strong>Note</strong>: For a more complete example allowing you to experiment with key range, have a look at our <a href="https://github.com/mdn/indexeddb-examples/tree/master/idbkeyrange">IDBKeyRange-example</a> repo (<a href="https://mdn.github.io/indexeddb-examples/idbkeyrange/">view the example live too</a>.)</p> </div> -<pre class="brush: js">function displayData() { +<pre class="brush: js notranslate">function displayData() { var keyRangeValue = IDBKeyRange.bound("A", "F"); var transaction = db.transaction(['fThings'], 'readonly'); |