Skip to main content

DbInfo

Defined in: src/data.ts:596

Represents metadata for a database/catalog in Datagrok.

Provides access to high-level database metadata such as schemas, relations, comments, and LLM-generated annotations. It also allows updating connection-level annotations and adding new relation metadata.

Mutation methods do not modify underlying database, they just create metadata in Datagrok.

Constructors

Constructor

new DbInfo(dart): DbInfo

Defined in: src/data.ts:604

Creates a new DbInfo wrapper.

Parameters

ParameterTypeDescription
dartanyThe underlying Dart object representing a database connection.

Returns

DbInfo

Properties

PropertyModifierTypeDefined in
dartpublicanysrc/data.ts:597

Accessors

comment

Get Signature

get comment(): string | undefined

Defined in: src/data.ts:622

Returns

string | undefined

Connection comment text, or an empty string if none exists.


connection

Get Signature

get connection(): DataConnection

Defined in: src/data.ts:656

The underlying DataConnection object.

Returns

DataConnection

A DataConnection wrapper.


llmComment

Get Signature

get llmComment(): string | undefined

Defined in: src/data.ts:629

Returns

string | undefined

User-defined comment used by AI query builder.


name

Get Signature

get name(): string

Defined in: src/data.ts:615

The name of the database/catalog.

Returns

string

The database name.

Methods

addRelation()

addRelation(fromTable, fromColumns, toTable, toColumns, props?): Promise<DbRelationInfo>

Defined in: src/data.ts:700

Creates and registers a logical (metadata-only) relation between two tables within this database connection.

This method does not modify the physical database schema. The relation is stored only as a Datagrok metadata annotation and is used for navigation, visualization, and AI-assisted features.

Parameters

ParameterTypeDescription
fromTablestringSource (child) table name.
fromColumnsstring[]Column(s) in the source table that participate in the relation.
toTablestringTarget (parent) table name.
toColumnsstring[]Column(s) in the target table that are referenced.
props?DbRelationPropertiesOptional relation metadata (e.g., cardinality, comments, primary path flag).

Returns

Promise<DbRelationInfo>

A promise that resolves to the newly created DbRelationInfo.

Example

const rel = await dbInfo.addRelation(
'orders',
['customer_id'],
'customers',
['id'],
{
cardinality: 'many-to-one'
}
);

clearProperties()

clearProperties(): Promise<void>

Defined in: src/data.ts:708

Removes all the meta data associated with the connection in Datagrok.

Returns

Promise<void>


getRelations()

getRelations(): Promise<DbRelationInfo[]>

Defined in: src/data.ts:647

Lists all known relations for this connection.

Returns

Promise<DbRelationInfo[]>

A promise resolving to an array of DbRelationInfo objects.


getSchemas()

getSchemas(): Promise<DbSchemaInfo[]>

Defined in: src/data.ts:638

Lists all schemas available for this database connection.

Returns

Promise<DbSchemaInfo[]>

A promise resolving to an array of DbSchemaInfo objects.


setComment()

setComment(comment): Promise<void>

Defined in: src/data.ts:662

Parameters

ParameterType
commentstring

Returns

Promise<void>


setLlmComment()

setLlmComment(comment): Promise<void>

Defined in: src/data.ts:666

Parameters

ParameterType
commentstring

Returns

Promise<void>