@mlagie/sql-connector 2.0.12 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -117,10 +117,9 @@ const userSchema = new Schema({
117
117
  type: Date,
118
118
  default: sqlTypeMap.CurrentTimestamp
119
119
  }
120
-
121
- module.exports = new Model("User", userSchema);
122
-
123
120
  });
121
+
122
+ module.exports = new Model("User", userSchema);
124
123
  ```
125
124
 
126
125
  ## Table synchronization
package/docs/fr/README.md CHANGED
@@ -53,6 +53,8 @@ await logout();
53
53
  | customize | `string` | Options SQL additionnelles |
54
54
 
55
55
  ```javascript
56
+ const { Schema, Model, sqlTypeMap } = require("@mlagie/sql-connector");
57
+
56
58
  const userSchema = new Schema({
57
59
  id: {
58
60
  type: Number,
@@ -86,6 +88,8 @@ const userSchema = new Schema({
86
88
  default: sqlTypeMap.CurrentTimestamp
87
89
  }
88
90
  });
91
+
92
+ module.exports = new Model("User", userSchema);
89
93
  ```
90
94
 
91
95
  ## Synchronisation des tables
package/index.d.ts CHANGED
@@ -119,20 +119,20 @@ export class Model {
119
119
  where?: Record<string, any>;
120
120
  order?: [string, string][];
121
121
  limit?: number;
122
- }): Promise<any[]>;
122
+ }): Promise<Array<ModelInstance>>;
123
123
  /**
124
124
  *
125
125
  * @param {Object} filter The filter criteria for the query. Should be an object where keys are column names and values are the values to filter by.
126
126
  * @returns {Promise<ModelInstance|number>} - A promise that resolves to a `ModelInstance` if a record is found, or `0` if no records match the filter.
127
127
  */
128
- count(filter?: Record<string, any>): Promise<any>;
128
+ count(filter?: Record<string, any>): Promise<ModelInstance | number>;
129
129
  /**
130
130
  * Runs a custom SQL_request query.
131
131
  * @param {string} custom The custom SQL_request query to execute.
132
132
  * @returns {Promise<void>} A promise that resolves when the query is executed.
133
133
  * @throws {Error} Throws an error if query execution fails.
134
134
  */
135
- customRequest(custom: string): Promise<any>;
135
+ customRequest(custom: string): Promise<ModelInstance>;
136
136
  /**
137
137
  * Deletes a record from the SQL table corresponding to the provided filter.
138
138
  *
@@ -143,7 +143,7 @@ export class Model {
143
143
  * or an instance of ModelInstance representing the deleted row.
144
144
  * @throws {Error} Throws an error if the SQL query fails.
145
145
  */
146
- delete(filter: Record<string, any>): Promise<number | ModelInstance>;
146
+ delete(filter: Record<string, any>): Promise<number>;
147
147
  /**
148
148
  * Asynchronously drops a table if it exists in the database.
149
149
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlagie/sql-connector",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "description": "The sql-connector module allows you to manage connections to a MySQL database, define table schemas, and interact with data in a simple and efficient way.",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -51,8 +51,8 @@
51
51
  "homepage": "https://github.com/mlagie/sql-connector#readme",
52
52
  "private": false,
53
53
  "dependencies": {
54
- "@mlagie/logger": "1.0.2",
55
- "mysql2": "3.23.1"
54
+ "@mlagie/logger": "1.0.5",
55
+ "mysql2": "3.23.2"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@eslint/js": "^10.0.1",
@@ -315,7 +315,7 @@ class Model {
315
315
  /**
316
316
  * Runs a custom SQL_request query.
317
317
  * @param {string} custom The custom SQL_request query to execute.
318
- * @returns {Promise<void>} A promise that resolves when the query is executed.
318
+ * @returns {Promise<ModelInstance>} A promise that resolves when the query is executed.
319
319
  * @throws {Error} Throws an error if query execution fails.
320
320
  */
321
321
  async customRequest(custom, custom_err_name = "") {
@@ -1,4 +1,4 @@
1
- const { error, logs } = require("@mlagie/logger");
1
+ const { error } = require("@mlagie/logger");
2
2
  const { getConnexion } = require("../db/connexion");
3
3
  const formatObject = require("../utils/formatObject");
4
4
  const generateCondition = require("../utils/generateCondition");
@@ -159,8 +159,6 @@ class ModelInstance {
159
159
  */
160
160
  async deleteOne() {
161
161
  const sql_request = `DELETE FROM ${this._name} WHERE ${generateCondition(formatObject(this.getRecordData()))}`;
162
-
163
- logs(sql_request)
164
162
  const rows = await getConnexion().promise().execute(sql_request).catch((err) => {
165
163
  error(`Error executing query deleteOne: ${err}`);
166
164
  throw err;