Skip to main content

DbInfo

Defined in: js-api/src/data.ts:759

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: js-api/src/data.ts:766

Creates a new DbInfo wrapper.

Parameters​

ParameterTypeDescription
dartanyThe underlying Dart object representing a database connection.

Returns​

DbInfo

Properties​

PropertyModifierTypeDefined in
dartpublicanyjs-api/src/data.ts:760

Accessors​

comment​

Get Signature​

get comment(): string | undefined

Defined in: js-api/src/data.ts:782

Returns​

string | undefined

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


connection​

Get Signature​

get connection(): DataConnection

Defined in: js-api/src/data.ts:812

The underlying DataConnection object.

Returns​

DataConnection

A DataConnection wrapper.


llmComment​

Get Signature​

get llmComment(): string | undefined

Defined in: js-api/src/data.ts:788

Returns​

string | undefined

User-defined comment used by AI query builder.


name​

Get Signature​

get name(): string

Defined in: js-api/src/data.ts:776

The name of the database/catalog.

Returns​

string

The database name.

Methods​

addRelation()​

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

Defined in: js-api/src/data.ts:855

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: js-api/src/data.ts:863

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

Returns​

Promise<void>


getRelations()​

getRelations(): Promise<DbRelationInfo[]>

Defined in: js-api/src/data.ts:804

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: js-api/src/data.ts:796

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: js-api/src/data.ts:818

Parameters​

ParameterType
commentstring

Returns​

Promise<void>


setLlmComment()​

setLlmComment(comment): Promise<void>

Defined in: js-api/src/data.ts:822

Parameters​

ParameterType
commentstring

Returns​

Promise<void>