diff --git a/.gitignore b/.gitignore index c5b1e3f..bdfd1ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -**/node_modules/ \ No newline at end of file +**/node_modules/ +.env \ No newline at end of file diff --git a/index.js b/index.js index c842cf1..3336757 100644 --- a/index.js +++ b/index.js @@ -263,7 +263,7 @@ class Instance { * Drops a whole database * - Requires admin privileges * @param {String} database - Name of the database to drop - * @returns {Any} + * @returns {OkPacket} */ async dropDatabase (database){ if (!database) throw new Error(`Can't drop database: No database given`); @@ -274,7 +274,7 @@ class Instance { /** * Drops a whole table * @param {String} table - Name of the table to drop - * @returns {Any} + * @returns {OkPacket} */ async dropTable(table){ if (!table) throw new Error("Can't drop table: No table set"); @@ -287,7 +287,7 @@ class Instance { * Creates a new database * - Requires admin privileges * @param {String} name - Name of the database to create - * @returns {Any} + * @returns {OkPacket} */ async createDatabase(name){ if (!name) throw new Error(`Can't create database: No name given`); @@ -385,7 +385,7 @@ class Instance { /** * Returns total amount of rows of a table * @param {String} table - Table name - * @returns {Any} + * @returns {Number} */ async total(table){ if (!table) throw new Error("Can't get structure: table not given"); @@ -410,6 +410,18 @@ class Instance { * @property {Array} passed - String representation of passed checks */ +/** + * @typedef {Object} OkPacket + * @property {Number} fieldCount - Defaults to 0 on non-select queries + * @property {Number} affectedRows - The number of rows affected by the query + * @property {Number} insertId - The ID of the last inserted row if the table has an auto-increment column; otherwise always 0 + * @property {Number} serverStatus - A status flag representing the current state of the mysql server + * @property {Number} warningCount - The number of warnings generated during query execution. + * @property {String} message - An optional message providin additional information about the query result (normally empty) + * @property {Boolean} protocol41 - Whether mysql protocol 4.1 or later is used + * @property {Number} changedRows - The number of rows actually changed by the query + */ + const awSQLInstance = new awSQL(); module.exports = {awSQL: awSQLInstance, Structure}; diff --git a/lib/Delete.js b/lib/Delete.js index 19dba9d..126bc5d 100644 --- a/lib/Delete.js +++ b/lib/Delete.js @@ -57,7 +57,7 @@ class Delete { /** * Executes the prepared querry - * @returns {Any} + * @returns {import("../index").OkPacket} */ async execute(){ if (!this.#instance.isConnected()) throw new Error(`Can't execute query: Instance has no connection`); diff --git a/lib/Insert.js b/lib/Insert.js index 0d62f39..fac3d68 100644 --- a/lib/Insert.js +++ b/lib/Insert.js @@ -42,7 +42,7 @@ class Insert { /** * Executes the prepared querry - * @returns {Any} + * @returns {import("../index").OkPacket} */ async execute(){ if (!this.#data) throw new Error("Insert: tried to insert without data"); diff --git a/lib/Tables.js b/lib/Tables.js index 536c523..108a1ae 100644 --- a/lib/Tables.js +++ b/lib/Tables.js @@ -44,7 +44,7 @@ class AlterTable { /** * Executes the prepared querry - * @returns {Any} + * @returns {import("../index").CheckResult} */ async execute(){ if (!this.#database) throw new Error(`Can't alter table ${this.#name}: Database not selected`); @@ -170,7 +170,7 @@ class CreateTable { /** * Executes the prepared querry - * @returns {Any} + * @returns {import("../index").OkPacket} */ async execute(){ if (!this.#database) throw new Error(`Can't create table ${this.#name}: Database not selected`); diff --git a/lib/Update.js b/lib/Update.js index b868a34..d9e7fbd 100644 --- a/lib/Update.js +++ b/lib/Update.js @@ -69,7 +69,7 @@ class Update{ /** * Executes the prepared querry - * @returns {Any} + * @returns {import("../index").OkPacket} */ async execute(){ if (!this.#instance.isConnected()) throw new Error(`Can't execute query: Instance has no connection`); diff --git a/package-lock.json b/package-lock.json index 5675092..c144684 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,18 @@ { - "name": "awsql_refined", + "name": "awsql", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "awsql_refined", + "name": "awsql", "version": "1.0.0", "license": "ISC", "dependencies": { + "dotenv": "^16.4.7", "mysql": "^2.18.1" - } + }, + "devDependencies": {} }, "node_modules/bignumber.js": { "version": "9.0.0", @@ -27,6 +29,18 @@ "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "license": "MIT" }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", diff --git a/package.json b/package.json index 58d90a8..5e359c1 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "author": "", "license": "ISC", "dependencies": { + "dotenv": "^16.4.7", "mysql": "^2.18.1" }, - "devDependencies": {}, "description": "" }