@finos/perspective
    Preparing search index...
    Index

    Methods

    • Returns string

    • 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].

      Returns Promise<void>

    • Returns the column names of this [Table] in "natural" order (the ordering implied by the input format).

      JavaScript Examples

      const columns = await table.columns();
      

      Returns Promise<any>

    • 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.

      Arguments

      • 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.

      JavaScript Examples

      const table = await client.table("x,y\n1,2\n3,4");

      // ...

      await table.delete({ lazy: true });

      Parameters

      Returns Promise<void>

    • Returns void

    • Get a copy of the [Client] this [Table] came from.

      Returns Promise<Client>

    • Returns the name of the index column for the table.

      JavaScript Examples

      const table = await client.table("x,y\n1,2\n3,4", { index: "x" });
      const index = table.get_index(); // "x"

      Returns Promise<undefined | string>

    • Returns the user-specified row limit for this table.

      Returns Promise<undefined | number>

    • Returns the user-specified name for this table, or the auto-generated name if a name was not specified when the table was created.

      Returns Promise<string>

    • 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.

      Returns Promise<number>

    • 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.

      Parameters

      • on_delete: Function

      Returns Promise<any>

    • Removes rows from this [Table] with the index column values supplied.

      Arguments

      • indices - A list of index column values for rows that should be removed.

      JavaScript Examples

      await table.remove([1, 2, 3]);
      

      Parameters

      Returns Promise<void>

    • Removes a listener with a given ID, as returned by a previous call to [Table::on_delete].

      Parameters

      • callback_id: number

      Returns Promise<any>

    • 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.

      JavaScript Examples

      await table.replace("x,y\n1,2");
      

      Parameters

      Returns Promise<void>

    • Returns 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 Promise<any>

    • Returns the number of rows in a [Table].

      Returns Promise<number>

    • 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.

      Arguments

      • 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].

      JavaScript Examples

      await table.update("x,y\n1,2");
      

      Parameters

      • input: string | ArrayBuffer | Record<string, unknown>[] | Record<string, unknown[]>
      • Optionaloptions: null | UpdateOptions

      Returns Promise<any>

    • Validates the given expressions.

      Parameters

      • exprs: any

      Returns Promise<any>

    • Create a new [View] from this table with a specified [ViewConfigUpdate].

      See [View] struct.

      JavaScript Examples

      const view = await table.view({
      columns: ["Sales"],
      aggregates: { Sales: "sum" },
      group_by: ["Region", "Country"],
      filter: [["Category", "in", ["Furniture", "Technology"]]],
      });

      Parameters

      Returns Promise<View>