@itrocks/mysql 0.0.26 → 0.1.1
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/cjs/mysql.d.ts +3 -0
- package/cjs/mysql.js +5 -0
- package/esm/mysql.d.ts +3 -0
- package/esm/mysql.js +5 -0
- package/package.json +3 -3
package/cjs/mysql.d.ts
CHANGED
|
@@ -47,6 +47,9 @@ export declare class Mysql extends DataSource {
|
|
|
47
47
|
propertiesToSearchSql(search: AnyObject): string;
|
|
48
48
|
propertiesToSql(object: object): string;
|
|
49
49
|
propertiesToSqlSelect<T extends object>(type: Type<T>): string;
|
|
50
|
+
query<T extends object>(type: Type<T>, query: string, values?: any): Promise<Awaited<T & {
|
|
51
|
+
id: Identifier;
|
|
52
|
+
}>[]>;
|
|
50
53
|
read<T extends object>(type: Type<T>, id: Identifier): Promise<Entity<T>>;
|
|
51
54
|
readCollection<T extends object, PT extends object>(object: Entity<T>, property: KeyOf<T>, type?: Type<PT>): Promise<Awaited<PT & {
|
|
52
55
|
id: Identifier;
|
package/cjs/mysql.js
CHANGED
|
@@ -157,6 +157,11 @@ class Mysql extends storage_1.DataSource {
|
|
|
157
157
|
}
|
|
158
158
|
return sql.join(', ');
|
|
159
159
|
}
|
|
160
|
+
async query(type, query, values) {
|
|
161
|
+
const connection = this.connection ?? await this.connect();
|
|
162
|
+
const rows = await connection.query(query, values);
|
|
163
|
+
return Promise.all(rows.map(row => this.valuesFromDb(row, type)));
|
|
164
|
+
}
|
|
160
165
|
async read(type, id) {
|
|
161
166
|
const connection = this.connection ?? await this.connect();
|
|
162
167
|
const propertiesSql = this.propertiesToSqlSelect(type);
|
package/esm/mysql.d.ts
CHANGED
|
@@ -47,6 +47,9 @@ export declare class Mysql extends DataSource {
|
|
|
47
47
|
propertiesToSearchSql(search: AnyObject): string;
|
|
48
48
|
propertiesToSql(object: object): string;
|
|
49
49
|
propertiesToSqlSelect<T extends object>(type: Type<T>): string;
|
|
50
|
+
query<T extends object>(type: Type<T>, query: string, values?: any): Promise<Awaited<T & {
|
|
51
|
+
id: Identifier;
|
|
52
|
+
}>[]>;
|
|
50
53
|
read<T extends object>(type: Type<T>, id: Identifier): Promise<Entity<T>>;
|
|
51
54
|
readCollection<T extends object, PT extends object>(object: Entity<T>, property: KeyOf<T>, type?: Type<PT>): Promise<Awaited<PT & {
|
|
52
55
|
id: Identifier;
|
package/esm/mysql.js
CHANGED
|
@@ -152,6 +152,11 @@ export class Mysql extends DataSource {
|
|
|
152
152
|
}
|
|
153
153
|
return sql.join(', ');
|
|
154
154
|
}
|
|
155
|
+
async query(type, query, values) {
|
|
156
|
+
const connection = this.connection ?? await this.connect();
|
|
157
|
+
const rows = await connection.query(query, values);
|
|
158
|
+
return Promise.all(rows.map(row => this.valuesFromDb(row, type)));
|
|
159
|
+
}
|
|
155
160
|
async read(type, id) {
|
|
156
161
|
const connection = this.connection ?? await this.connect();
|
|
157
162
|
const propertiesSql = this.propertiesToSqlSelect(type);
|
package/package.json
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"@itrocks/sort": "latest",
|
|
10
10
|
"@itrocks/storage": "latest",
|
|
11
11
|
"mariadb": "^3.4",
|
|
12
|
-
"typescript": "~5.
|
|
12
|
+
"typescript": "~5.9"
|
|
13
13
|
},
|
|
14
14
|
"description": "Transforms model objects to and from MySQL database records",
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/node": "^
|
|
16
|
+
"@types/node": "^24.10"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=18"
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"build:esm": "tsc -p tsconfig.esm.json"
|
|
60
60
|
},
|
|
61
61
|
"types": "./esm/mysql.d.ts",
|
|
62
|
-
"version": "0.
|
|
62
|
+
"version": "0.1.1"
|
|
63
63
|
}
|