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/utils.ts:1080

Properties

PropertyModifierType
dartpublicany

Accessors

comment

get comment(): string

Returns

string

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

Source

src/utils.ts:1098


connection

get connection(): DataConnection

The underlying DataConnection object.

Returns

DataConnection

A DataConnection wrapper.

Source

src/utils.ts:1132


llmComment

get llmComment(): string

Returns

string

User-defined comment used by AI query builder.

Source

src/utils.ts:1105


name

get name(): undefined | string

The name of the database. If database name is not set in connection details then this field is undefined.

Returns

undefined | string

The database name.

Source

src/utils.ts:1091


relations

get relations(): Promise <DbRelationInfo[]>

Lists all known relations for this connection.

Returns

Promise <DbRelationInfo[]>

A promise resolving to an array of DbRelationInfo objects.

Source

src/utils.ts:1123


schemas

get schemas(): Promise <DbSchemaInfo[]>

Lists all schemas available for this database connection.

Returns

Promise <DbSchemaInfo[]>

A promise resolving to an array of DbSchemaInfo objects.

Source

src/utils.ts:1114

Methods

addRelation()

addRelation(name, props): Promise <DbRelationInfo>

Creates and registers a new database relation for this connection. It's just only meta annotation which is stored in Datagrok and real database is not affected.

Parameters

ParameterTypeDescription
namestringRelation name.
propsDbRelationPropertiesRelation metadata, including table/column mappings.

Returns

Promise <DbRelationInfo>

A promise resolving to the newly created DbRelationInfo.

Example

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

Source

src/utils.ts:1167


clearProperties()

clearProperties(): Promise<void>

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

Returns

Promise<void>

Source

src/utils.ts:1174


setComment()

setComment(comment): Promise<void>

Parameters

ParameterType
commentstring

Returns

Promise<void>

Source

src/utils.ts:1138


setLlmComment()

setLlmComment(comment): Promise<void>

Parameters

ParameterType
commentstring

Returns

Promise<void>

Source

src/utils.ts:1142