TableInstance

class beneath.TableInstance[source]

Represents an instance of a Table, i.e. a specific version that you can query/subscribe/write to. Learn more about instances at https://about.beneath.dev/docs/concepts/tables/.

table: Table

The table that this is an instance of

instance_id: uuid.UUID

The table instance ID

is_final: bool

True if the instance has been made final and is closed for further writes

is_primary: bool

True if the instance is the primary instance for the table

version: int

The instance’s version number

async update(make_primary=None, make_final=None)[source]

Updates the instance

async delete()[source]

Deletes the instance

async query_log(peek: bool = False)beneath.cursor.Cursor[source]

Queries the table’s log, returning a cursor for replaying every record written to the instance or for subscribing to new changes records in the table.

Parameters

peek (bool) – If true, returns a cursor for the most recent records and lets you page through the log in reverse order.

async query_index(filter: Optional[str] = None)beneath.cursor.Cursor[source]

Queries a sorted index of the records written to the table. The index contains the newest record for each record key (see the table’s schema for the key). Returns a cursor for paging through the index.

Parameters

filter (str) – A filter to apply to the index. Filters allow you to quickly find specific record(s) in the index based on the record key. For details on the filter syntax, see https://about.beneath.dev/docs/reading-writing-data/index-filters/.

async write(records: Union[collections.abc.Mapping, Iterable[collections.abc.Mapping]])[source]

Convenience wrapper for Client.write