MCPcopy Create free account
hub / github.com/antvis/AVA / load

Method load

src/remote/sqlserver/engine.ts:63–85  ·  view source on GitHub ↗
(configs: DataSourceConfig | DataSourceConfig[])

Source from the content-addressed store, hash-verified

61 }
62
63 async load(configs: DataSourceConfig | DataSourceConfig[]): Promise<void> {
64 const sources = Array.isArray(configs) ? configs : [configs];
65 if (sources.length !== 1) {
66 throw new Error(`SQLServerEngine currently supports exactly one data source, received ${sources.length}`);
67 }
68 const config = sources[0];
69 await this.dispose();
70 if (config.type !== 'sqlserver') {
71 throw new Error(`SQLServerEngine only supports 'sqlserver' data sources, got '${config.type}'`);
72 }
73 // eslint-disable-next-line import/no-named-as-default-member -- see the comment on the mssql import
74 this.pool = new mssql.ConnectionPool(connectionConfig(config.options));
75 // Request promises report transport errors. A pool-level listener also prevents
76 // idle-connection errors from becoming unhandled EventEmitter exceptions.
77 this.pool.on('error', () => undefined);
78 try {
79 await this.pool.connect();
80 this.sourceSchema = config.options.schema;
81 } catch (error) {
82 await this.dispose();
83 throw error;
84 }
85 }
86
87 async schema(): Promise<Schema> {
88 if (!this.pool) throw new Error('No data loaded. Please call source() first.');

Callers 1

loadFunction · 0.95

Calls 2

disposeMethod · 0.95
connectionConfigFunction · 0.85

Tested by 1

loadFunction · 0.76