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():string
Returns
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():string
Returns
string
User-defined comment used by AI query builder.
Source
name
getname():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
relations
getrelations():Promise<DbRelationInfo[]>
Lists all known relations for this connection.
Returns
Promise <DbRelationInfo[]>
A promise resolving to an array of DbRelationInfo objects.
Source
schemas
getschemas():Promise<DbSchemaInfo[]>
Lists all schemas available for this database connection.
Returns
Promise <DbSchemaInfo[]>
A promise resolving to an array of DbSchemaInfo objects.
Source
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
| Parameter | Type | Description |
|---|---|---|
name | string | Relation name. |
props | DbRelationProperties | Relation 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
clearProperties()
clearProperties():
Promise<void>
Removes all the meta data associated with the connection in Datagrok.
Returns
Promise<void>
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>