Skip to main content

DbInfo

Represents metadata for a database connection 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

new DbInfo()

new DbInfo(dart): DbInfo

Creates a new DbInfo wrapper.

Parameters

ParameterTypeDescription
dartanyThe underlying Dart object representing a database connection.

Returns

DbInfo

Source

src/data.ts:606

Properties

PropertyModifierType
dartpublicany

Accessors

comment

get comment(): undefined | string

Returns

undefined | string

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

Source

src/data.ts:624


connection

get connection(): DataConnection

The underlying DataConnection object.

Returns

DataConnection

A DataConnection wrapper.

Source

src/data.ts:658


llmComment

get llmComment(): undefined | string

Returns

undefined | string

User-defined comment used by AI query builder.

Source

src/data.ts:631


name

get name(): string

The name of the database.

Returns

string

The database name.

Source

src/data.ts:617

Methods

addRelation()

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

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'
}
);

Source

src/data.ts:702


clearProperties()

clearProperties(): Promise<void>

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

Returns

Promise<void>

Source

src/data.ts:710


getRelations()

getRelations(): Promise <DbRelationInfo[]>

Lists all known relations for this connection.

Returns

Promise <DbRelationInfo[]>

A promise resolving to an array of DbRelationInfo objects.

Source

src/data.ts:649


getSchemas()

getSchemas(): Promise <DbSchemaInfo[]>

Lists all schemas available for this database connection.

Returns

Promise <DbSchemaInfo[]>

A promise resolving to an array of DbSchemaInfo objects.

Source

src/data.ts:640


setComment()

setComment(comment): Promise<void>

Parameters

ParameterType
commentstring

Returns

Promise<void>

Source

src/data.ts:664


setLlmComment()

setLlmComment(comment): Promise<void>

Parameters

ParameterType
commentstring

Returns

Promise<void>

Source

src/data.ts:668