Delete this [Table] and cleans up associated resources.
[Table]s do not stop consuming resources or processing updates when
they are garbage collected in their host language - you must call
this method to reclaim these.
options An options dictionary.
lazy Whether to delete this [Table] lazily. When false (the
default), the delete will occur immediately, assuming it has no
[View] instances registered to it (which must be deleted first,
otherwise this method will throw an error). When true, the
[Table] will only be marked for deltion once its [View]
dependency count reaches 0.const table = await client.table("x,y\n1,2\n3,4");
// ...
await table.delete({ lazy: true });
Optionaloptions: null | DeleteOptionsGet a copy of the [Client] this [Table] came from.
Returns the user-specified row limit for this table.
Returns the user-specified name for this table, or the auto-generated name if a name was not specified when the table was created.
Create a unique channel ID on this [Table], which allows
View::on_update callback calls to be associated with the
Table::update which caused them.
Register a callback which is called exactly once, when this [Table] is
deleted with the [Table::delete] method.
[Table::on_delete] resolves when the subscription message is sent, not
when the delete event occurs.
Removes a listener with a given ID, as returned by a previous call to
[Table::on_delete].
Replace all rows in this [Table] with the input data, coerced to this
[Table]'s existing [perspective_client::Schema], notifying any
derived [View] and [View::on_update] callbacks.
Calling [Table::replace] is an easy way to replace all the data in a
[Table] without losing any derived [View] instances or
[View::on_update] callbacks. [Table::replace] does not infer
data types like [Client::table] does, rather it coerces input
data to the Schema like [Table::update]. If you need a [Table]
with a different Schema, you must create a new one.
await table.replace("x,y\n1,2");
Optionaloptions: null | UpdateOptionsReturns a table's [Schema], a mapping of column names to column types.
The mapping of a [Table]'s column names to data types is referred to
as a [Schema]. Each column has a unique name and a data type, one
of:
"boolean" - A boolean type"date" - A timesonze-agnostic date type (month/day/year)"datetime" - A millisecond-precision datetime type in the UTC
timezone"float" - A 64 bit float"integer" - A signed 32 bit integer (the integer type supported by
JavaScript)"string" - A [String] data type (encoded internally as a
dictionary)Note that all [Table] columns are nullable, regardless of the data
type.
Returns the number of rows in a [Table].
Updates the rows of this table and any derived [View] instances.
Calling [Table::update] will trigger the [View::on_update] callbacks
register to derived [View], and the call itself will not resolve until
all derived [View]'s are notified.
When updating a [Table] with an index, [Table::update] supports
partial updates, by omitting columns from the update data.
input - The input data for this [Table]. The schema of a [Table]
is immutable after creation, so this method cannot be called with a
schema.options - Options for this update step - see [UpdateOptions].await table.update("x,y\n1,2");
Optionaloptions: null | UpdateOptionsValidates the given expressions.
Create a new [View] from this table with a specified
[ViewConfigUpdate].
See [View] struct.
const view = await table.view({
columns: ["Sales"],
aggregates: { Sales: "sum" },
group_by: ["Region", "Country"],
filter: [["Category", "in", ["Furniture", "Technology"]]],
});
Optionalconfig: null | ViewConfigUpdate
Removes all the rows in the [
Table], but preserves everything else including the schema, index, and any callbacks or registered [View] instances.Calling [
Table::clear], like [Table::update] and [Table::remove], will trigger an update event to any registered listeners via [View::on_update].