node-firebird-driver-native
Version:
Firebird Native Driver for Node.js
50 lines • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClientImpl = exports.getDefaultLibraryFilename = void 0;
exports.createNativeClient = createNativeClient;
const attachment_1 = require("./attachment");
const impl_1 = require("node-firebird-driver/dist/lib/impl");
const fb = require("node-firebird-native-api");
/** Gets the default platform Firebird client library filename. */
var node_firebird_native_api_1 = require("node-firebird-native-api");
Object.defineProperty(exports, "getDefaultLibraryFilename", { enumerable: true, get: function () { return node_firebird_native_api_1.getDefaultLibraryFilename; } });
/** Creates a client for a given library filename. */
function createNativeClient(library) {
return new ClientImpl(library);
}
/** Client implementation. */
class ClientImpl extends impl_1.AbstractClient {
constructor(library) {
super();
this.master = fb.getMaster(library);
this.dispatcher = this.master.getDispatcherSync();
this.util = this.master.getUtilInterfaceSync();
}
async statusAction(action) {
const status = this.master.getStatusSync();
try {
return await action(status);
}
finally {
status.disposeSync();
}
}
/** Connects to a database. */
async internalConnect(uri, options) {
return await attachment_1.AttachmentImpl.connect(this, uri, options);
}
/** Creates a database. */
async internalCreateDatabase(uri, options) {
return await attachment_1.AttachmentImpl.createDatabase(this, uri, options);
}
/** Disposes this client's resources. */
async internalDispose() {
this.dispatcher.releaseSync();
fb.disposeMaster(this.master);
this.util = undefined;
this.dispatcher = undefined;
this.master = undefined;
}
}
exports.ClientImpl = ClientImpl;
//# sourceMappingURL=client.js.map