Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# IndexedDB

This CDP domain is experimental.

- Types

- Commands

- Events

## Types

Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.

class DatabaseWithObjectStores(name, version, object_stores)

  Database with an array of object stores.

  name: `str`

    Database name.

  version: `float`

    Database version (type is not ‘integer’, as the standard requires the version number to be ‘unsigned long long’)

  object_stores: `List`[`ObjectStore`]

    Object stores in this database.

class ObjectStore(name, key_path, auto_increment, indexes)

  Object store.

  name: `str`

    Object store name.

  key_path: `KeyPath`

    Object store key path.

  auto_increment: `bool`

    If true, object store has auto increment flag set.

  indexes: `List`[`ObjectStoreIndex`]

    Indexes in this object store.

class ObjectStoreIndex(name, key_path, unique, multi_entry)

  Object store index.

  name: `str`

    Index name.

  key_path: `KeyPath`

    Index key path.

  unique: `bool`

    If true, index is unique.

  multi_entry: `bool`

    If true, index allows multiple entries for a key.

class Key(type_, number=None, string=None, date=None, array=None)

  Key.

  type_: `str`

    Key type.

  number: `Optional`[`float`] = None

    Number value.

  string: `Optional`[`str`] = None

    String value.

  date: `Optional`[`float`] = None

    Date value.

  array: `Optional`[`List`[`Key`]] = None

    Array value.

class KeyRange(lower_open, upper_open, lower=None, upper=None)

  Key range.

  lower_open: `bool`

    If true lower bound is open.

  upper_open: `bool`

    If true upper bound is open.

  lower: `Optional`[`Key`] = None

    Lower bound.

  upper: `Optional`[`Key`] = None

    Upper bound.

class DataEntry(key, primary_key, value)

  Data entry.

  key: `RemoteObject`

    Key object.

  primary_key: `RemoteObject`

    Primary key object.

  value: `RemoteObject`

    Value object.

class KeyPath(type_, string=None, array=None)

  Key path.

  type_: `str`

    Key path type.

  string: `Optional`[`str`] = None

    String value.

  array: `Optional`[`List`[`str`]] = None

    Array value.

## Commands

Each command is a generator function. The return type `Generator[x, y, z]` indicates that the generator yields arguments of type `x`, it must be resumed with an argument of type `y`, and it returns type `z`. In this library, types `x` and `y` are the same for all commands, and `z` is the return type you should pay attention to. For more information, see Getting Started: Commands.

clear_object_store(database_name, object_store_name, security_origin=None, storage_key=None, storage_bucket=None)

  Clears all entries from an object store.

  Parameters:

    - security_origin (`Optional`[`str`]) – (Optional) At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.

    - storage_key (`Optional`[`str`]) – (Optional) Storage key.

    - storage_bucket (`Optional`[`StorageBucket`]) – (Optional) Storage bucket. If not specified, it uses the default bucket.

    - database_name (`str`) – Database name.

    - object_store_name (`str`) – Object store name.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

delete_database(database_name, security_origin=None, storage_key=None, storage_bucket=None)

  Deletes a database.

  Parameters:

    - security_origin (`Optional`[`str`]) – (Optional) At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.

    - storage_key (`Optional`[`str`]) – (Optional) Storage key.

    - storage_bucket (`Optional`[`StorageBucket`]) – (Optional) Storage bucket. If not specified, it uses the default bucket.

    - database_name (`str`) – Database name.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

delete_object_store_entries(database_name, object_store_name, key_range, security_origin=None, storage_key=None, storage_bucket=None)

  Delete a range of entries from an object store

  Parameters:

    - security_origin (`Optional`[`str`]) – (Optional) At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.

    - storage_key (`Optional`[`str`]) – (Optional) Storage key.

    - storage_bucket (`Optional`[`StorageBucket`]) – (Optional) Storage bucket. If not specified, it uses the default bucket.

    - database_name (`str`) –

    - object_store_name (`str`) –

    - key_range (`KeyRange`) – Range of entry keys to delete

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

disable()

  Disables events from backend.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

enable()

  Enables events from backend.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

get_metadata(database_name, object_store_name, security_origin=None, storage_key=None, storage_bucket=None)

  Gets metadata of an object store.

  Parameters:

    - security_origin (`Optional`[`str`]) – (Optional) At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.

    - storage_key (`Optional`[`str`]) – (Optional) Storage key.

    - storage_bucket (`Optional`[`StorageBucket`]) – (Optional) Storage bucket. If not specified, it uses the default bucket.

    - database_name (`str`) – Database name.

    - object_store_name (`str`) – Object store name.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `Tuple`[`float`, `float`]]

  Returns:

    A tuple with the following items:

    0. entriesCount - the entries count

    1. keyGeneratorValue - the current value of key generator, to become the next inserted key into the object store. Valid if objectStore.autoIncrement is true.

request_data(database_name, object_store_name, index_name, skip_count, page_size, security_origin=None, storage_key=None, storage_bucket=None, key_range=None)

  Requests data from object store or index.

  Parameters:

    - security_origin (`Optional`[`str`]) – (Optional) At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.

    - storage_key (`Optional`[`str`]) – (Optional) Storage key.

    - storage_bucket (`Optional`[`StorageBucket`]) – (Optional) Storage bucket. If not specified, it uses the default bucket.

    - database_name (`str`) – Database name.

    - object_store_name (`str`) – Object store name.

    - index_name (`str`) – Index name, empty string for object store data requests.

    - skip_count (`int`) – Number of records to skip.

    - page_size (`int`) – Number of records to fetch.

    - key_range (`Optional`[`KeyRange`]) – (Optional) Key range.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `Tuple`[`List`[`DataEntry`], `bool`]]

  Returns:

    A tuple with the following items:

    0. objectStoreDataEntries - Array of object store data entries.

    1. hasMore - If true, there are more entries to fetch in the given range.

request_database(database_name, security_origin=None, storage_key=None, storage_bucket=None)

  Requests database with given name in given frame.

  Parameters:

    - security_origin (`Optional`[`str`]) – (Optional) At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.

    - storage_key (`Optional`[`str`]) – (Optional) Storage key.

    - storage_bucket (`Optional`[`StorageBucket`]) – (Optional) Storage bucket. If not specified, it uses the default bucket.

    - database_name (`str`) – Database name.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `DatabaseWithObjectStores`]

  Returns:

    Database with an array of object stores.

request_database_names(security_origin=None, storage_key=None, storage_bucket=None)

  Requests database names for given security origin.

  Parameters:

    - security_origin (`Optional`[`str`]) – (Optional) At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.

    - storage_key (`Optional`[`str`]) – (Optional) Storage key.

    - storage_bucket (`Optional`[`StorageBucket`]) – (Optional) Storage bucket. If not specified, it uses the default bucket.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `List`[`str`]]

  Returns:

    Database names for origin.

## Events

There are no events in this module.