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
| Parameter | Type | Description |
|---|---|---|
dart | any | The underlying Dart object representing a database connection. |
Returns
Source
Properties
| Property | Modifier | Type |
|---|---|---|
dart | public | any |
Accessors
comment
getcomment():undefined|string
Returns
undefined | string
Connection comment text, or an empty string if none exists.
Source
connection
getconnection():DataConnection
The underlying DataConnection object.
Returns
A DataConnection wrapper.
Source
llmComment
getllmComment():undefined|string
Returns
undefined | string
User-defined comment used by AI query builder.
Source
name
getname():string
The name of the database.
Returns
string
The database name.
Source
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
| Parameter | Type | Description |
|---|---|---|
fromTable | string | Source (child) table name. |
fromColumns | string[] | Column(s) in the source table that participate in the relation. |
toTable | string | Target (parent) table name. |
toColumns | string[] | Column(s) in the target table that are referenced. |
props? | DbRelationProperties | Optional 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
clearProperties()
clearProperties():
Promise<void>
Removes all the meta data associated with the connection in Datagrok.
Returns
Promise<void>
Source
getRelations()
getRelations():
Promise<DbRelationInfo[]>
Lists all known relations for this connection.
Returns
Promise <DbRelationInfo[]>
A promise resolving to an array of DbRelationInfo objects.
Source
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
setComment()
setComment(
comment):Promise<void>
Parameters
| Parameter | Type |
|---|---|
comment | string |
Returns
Promise<void>
Source
setLlmComment()
setLlmComment(
comment):Promise<void>
Parameters
| Parameter | Type |
|---|---|
comment | string |
Returns
Promise<void>