Table of Contents

Class IDBKeyRange

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The IDBKeyRange interface of the IndexedDB API represents a continuous interval over some data type that is used for keys. Records can be retrieved from IDBObjectStore and 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.

[Value("IDBKeyRange")]
public class IDBKeyRange
Inheritance
IDBKeyRange
Inherited Members

Remarks

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 bounded; if it has no bounds, it is unbounded. 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:

Range

Code

All keys ≥ x

IDBKeyRange.lowerBound(x)

All keys > x

IDBKeyRange.lowerBound(x, true)

All keys ≤ y

IDBKeyRange.upperBound(y)

All keys < y

IDBKeyRange.upperBound(y, true)

All keys ≥ x && ≤ y

IDBKeyRange.bound(x, y)

All keys > x &&< y

IDBKeyRange.bound(x, y, true, true)

All keys > x && ≤ y

IDBKeyRange.bound(x, y, true, false)

All keys ≥ x &&< y

IDBKeyRange.bound(x, y, false, true)

The key = z

IDBKeyRange.only(z)

A key is in a key range if the following conditions are true:

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Constructors

IDBKeyRange()

public IDBKeyRange()

Properties

Lower

The lower read-only property of the
IDBKeyRange interface returns the lower bound of the key range.

[Value("lower")]
public dynamic Lower { get; }

Property Value

dynamic

The lower bound of the key range (can be any
type.)

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

LowerOpen

The lowerOpen read-only property of the
IDBKeyRange interface returns a boolean indicating whether the
lower-bound value is included in the key range.

[Value("lowerOpen")]
public bool LowerOpen { get; }

Property Value

bool

A boolean value:

ValueIndication
trueThe lower-bound value is not included in the key range.
falseThe lower-bound value is included in the key range.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Upper

The upper read-only property of the
IDBKeyRange interface returns the upper bound of the key range.

[Value("upper")]
public dynamic Upper { get; }

Property Value

dynamic

The upper bound of the key range (can be any type.)

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

UpperOpen

The upperOpen read-only property of the
IDBKeyRange interface returns a boolean indicating whether the
upper-bound value is included in the key range.

[Value("upperOpen")]
public bool UpperOpen { get; }

Property Value

bool

A boolean value:

ValueIndication
trueThe upper-bound value is not included in the key range.
falseThe upper-bound value is included in the key range.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Methods

Bound(dynamic, dynamic, bool, bool)

The bound() static method of the IDBKeyRange
interface creates a new key range with the specified upper and lower bounds. The
bounds can be open (that is, the bounds exclude the endpoint values) or closed (that
is, the bounds include the endpoint values). By default, the bounds are closed.

[Value("bound")]
public static IDBKeyRange Bound(dynamic lower, dynamic upper, bool lowerOpen = false, bool upperOpen = false)

Parameters

lower dynamic
upper dynamic
lowerOpen bool
upperOpen bool

Returns

IDBKeyRange

IDBKeyRange: The newly created key range.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Includes(dynamic)

The includes() method of the IDBKeyRange
interface returns a boolean indicating whether a specified key is inside the key
range.

[Value("includes")]
public bool Includes(dynamic key)

Parameters

key dynamic

Returns

bool

A boolean value.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

LowerBound(dynamic, bool)

The lowerBound() static method of the
IDBKeyRange interface creates a new key range with only a lower bound.
By default, it includes the lower endpoint value and is closed.

[Value("lowerBound")]
public static IDBKeyRange LowerBound(dynamic lower, bool open = false)

Parameters

lower dynamic
open bool

Returns

IDBKeyRange

IDBKeyRange: The newly created key range.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Only(dynamic)

The only() static method of the IDBKeyRange
interface creates a new key range containing a single value.

[Value("only")]
public static IDBKeyRange Only(dynamic value)

Parameters

value dynamic

Returns

IDBKeyRange

IDBKeyRange: The newly created key range.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

UpperBound(dynamic, bool)

The upperBound() static method of the
IDBKeyRange interface creates a new upper-bound key range. By default,
it includes the upper endpoint value and is closed.

[Value("upperBound")]
public static IDBKeyRange UpperBound(dynamic upper, bool open = false)

Parameters

upper dynamic
open bool

Returns

IDBKeyRange

IDBKeyRange: The newly created key range.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN