This commit is contained in:
Sam 2025-04-13 14:36:47 +02:00
parent 68f75f12d9
commit 731f522578

View File

@ -16,6 +16,7 @@ const { throwTypeError } = require("./lib/Errors");
* @property {Boolean} [insecureAuth] - Whether insecure authentication methods should be allowed * @property {Boolean} [insecureAuth] - Whether insecure authentication methods should be allowed
* @property {String} [customIdentifier] - Sets a custom identifier for this instance * @property {String} [customIdentifier] - Sets a custom identifier for this instance
* @property {Boolean} [isDefault] - Whether this instance is returned by default via 'getInstance' * @property {Boolean} [isDefault] - Whether this instance is returned by default via 'getInstance'
* @property {object} [ssl] - Whether to use ssl
*/ */
/** /**
@ -40,6 +41,7 @@ class awSQL {
insecureAuth: false, insecureAuth: false,
customIdentifier: false, customIdentifier: false,
isDefault: false, isDefault: false,
ssl: false,
}){ }){
if (!password) throw new Error(`Can't create instance: No password given`); if (!password) throw new Error(`Can't create instance: No password given`);
if (!username) throw new Error(`Can't create instance: No username given`); if (!username) throw new Error(`Can't create instance: No username given`);
@ -106,9 +108,10 @@ class Instance {
#multipleStatements; #multipleStatements;
#charset; #charset;
#connection; #connection;
#ssl;
#selectedDatabase; #selectedDatabase;
constructor(hostname="localhost", username, password, charset="utf8mb4", defaultDatabase=false, multipleStatements=false, insecureAuth=false){ constructor(hostname="localhost", username, password, charset="utf8mb4", defaultDatabase=false, multipleStatements=false, insecureAuth=false, ssl=false){
this.#host = hostname; this.#host = hostname;
this.#user = username; this.#user = username;
this.#password = password; this.#password = password;
@ -116,6 +119,7 @@ class Instance {
this.#multipleStatements = multipleStatements; this.#multipleStatements = multipleStatements;
this.#insecureAuth = insecureAuth; this.#insecureAuth = insecureAuth;
this.#selectedDatabase = defaultDatabase||username; this.#selectedDatabase = defaultDatabase||username;
this.#ssl = ssl;
} }
/** /**
@ -130,7 +134,8 @@ class Instance {
host: this.#host, host: this.#host,
insecureAuth: this.#insecureAuth, insecureAuth: this.#insecureAuth,
multipleStatements: this.#multipleStatements, multipleStatements: this.#multipleStatements,
charset: this.#charset charset: this.#charset,
ssl: this.#ssl
}); });
this.#connection = connection; // Store the connection this.#connection = connection; // Store the connection
connection.connect((err) =>{ connection.connect((err) =>{