@itrocks/mysql 0.0.11 → 0.0.13
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 +1 -3
- package/cjs/mysql.js +4 -4
- package/esm/mysql.d.ts +1 -3
- package/esm/mysql.js +4 -4
- package/package.json +1 -1
package/cjs/mysql.d.ts
CHANGED
|
@@ -48,9 +48,7 @@ export declare class Mysql extends DataSource {
|
|
|
48
48
|
id: Identifier;
|
|
49
49
|
}>[]>;
|
|
50
50
|
readCollectionIds<T extends object, PT extends object>(object: Entity<T>, property: KeyOf<T>, type?: Type<PT>): Promise<Identifier[]>;
|
|
51
|
-
readMultiple<T extends object>(type: Type<T>, ids: Identifier[]): Promise<
|
|
52
|
-
id: Identifier;
|
|
53
|
-
}>[]>;
|
|
51
|
+
readMultiple<T extends object>(type: Type<T>, ids: Identifier[]): Promise<Entity<T>[]>;
|
|
54
52
|
save<T extends object>(object: MayEntity<T>): Promise<Entity<T>>;
|
|
55
53
|
search<T extends object>(type: Type<T>, search?: SearchType<T>): Promise<Entity<T>[]>;
|
|
56
54
|
update<T extends object>(object: Entity<T>): Promise<Entity<T>>;
|
package/cjs/mysql.js
CHANGED
|
@@ -51,7 +51,7 @@ class Mysql extends storage_1.DataSource {
|
|
|
51
51
|
async deleteRelatedId(object, property, id) {
|
|
52
52
|
const connection = this.connection ?? await this.connect();
|
|
53
53
|
const objectTable = depends.storeOf(object);
|
|
54
|
-
const propertyTable = depends.storeOf(new reflect_2.ReflectProperty(object, property).collectionType.elementType);
|
|
54
|
+
const propertyTable = depends.storeOf(new reflect_2.ReflectProperty(object, property).collectionType.elementType.type);
|
|
55
55
|
const joinTable = [objectTable, propertyTable].sort().join('_');
|
|
56
56
|
const query = 'DELETE FROM `' + joinTable + '` WHERE ' + objectTable + '_id = ? AND ' + propertyTable + '_id = ?';
|
|
57
57
|
const values = [object.id, id];
|
|
@@ -77,7 +77,7 @@ class Mysql extends storage_1.DataSource {
|
|
|
77
77
|
async insertRelatedId(object, property, id) {
|
|
78
78
|
const connection = this.connection ?? await this.connect();
|
|
79
79
|
const objectTable = depends.storeOf(object);
|
|
80
|
-
const propertyTable = depends.storeOf(new reflect_2.ReflectProperty(object, property).collectionType.elementType);
|
|
80
|
+
const propertyTable = depends.storeOf(new reflect_2.ReflectProperty(object, property).collectionType.elementType.type);
|
|
81
81
|
const joinTable = [objectTable, propertyTable].sort().join('_');
|
|
82
82
|
const query = 'INSERT INTO `' + joinTable + '` SET ' + objectTable + '_id = ?, ' + propertyTable + '_id = ?';
|
|
83
83
|
const values = [object.id, id];
|
|
@@ -127,7 +127,7 @@ class Mysql extends storage_1.DataSource {
|
|
|
127
127
|
const rows = await connection.query('SELECT ' + propertiesSql + ' FROM `' + depends.storeOf(type) + '` WHERE id = ?', [id]);
|
|
128
128
|
return this.valuesFromDb(rows[0], type);
|
|
129
129
|
}
|
|
130
|
-
async readCollection(object, property, type = new reflect_2.ReflectProperty(object, property).collectionType.elementType) {
|
|
130
|
+
async readCollection(object, property, type = new reflect_2.ReflectProperty(object, property).collectionType.elementType.type) {
|
|
131
131
|
const connection = this.connection ?? await this.connect();
|
|
132
132
|
const propertiesSql = this.propertiesToSqlSelect(type);
|
|
133
133
|
const objectTable = depends.storeOf(object);
|
|
@@ -145,7 +145,7 @@ class Mysql extends storage_1.DataSource {
|
|
|
145
145
|
const rows = await connection.query(query, [object.id]);
|
|
146
146
|
return Promise.all(rows.map(row => this.valuesFromDb(row, type)));
|
|
147
147
|
}
|
|
148
|
-
async readCollectionIds(object, property, type = new reflect_2.ReflectProperty(object, property).collectionType.elementType) {
|
|
148
|
+
async readCollectionIds(object, property, type = new reflect_2.ReflectProperty(object, property).collectionType.elementType.type) {
|
|
149
149
|
const connection = this.connection ?? await this.connect();
|
|
150
150
|
const objectTable = depends.storeOf(object);
|
|
151
151
|
const propertyTable = depends.storeOf(type);
|
package/esm/mysql.d.ts
CHANGED
|
@@ -48,9 +48,7 @@ export declare class Mysql extends DataSource {
|
|
|
48
48
|
id: Identifier;
|
|
49
49
|
}>[]>;
|
|
50
50
|
readCollectionIds<T extends object, PT extends object>(object: Entity<T>, property: KeyOf<T>, type?: Type<PT>): Promise<Identifier[]>;
|
|
51
|
-
readMultiple<T extends object>(type: Type<T>, ids: Identifier[]): Promise<
|
|
52
|
-
id: Identifier;
|
|
53
|
-
}>[]>;
|
|
51
|
+
readMultiple<T extends object>(type: Type<T>, ids: Identifier[]): Promise<Entity<T>[]>;
|
|
54
52
|
save<T extends object>(object: MayEntity<T>): Promise<Entity<T>>;
|
|
55
53
|
search<T extends object>(type: Type<T>, search?: SearchType<T>): Promise<Entity<T>[]>;
|
|
56
54
|
update<T extends object>(object: Entity<T>): Promise<Entity<T>>;
|
package/esm/mysql.js
CHANGED
|
@@ -47,7 +47,7 @@ export class Mysql extends DataSource {
|
|
|
47
47
|
async deleteRelatedId(object, property, id) {
|
|
48
48
|
const connection = this.connection ?? await this.connect();
|
|
49
49
|
const objectTable = depends.storeOf(object);
|
|
50
|
-
const propertyTable = depends.storeOf(new ReflectProperty(object, property).collectionType.elementType);
|
|
50
|
+
const propertyTable = depends.storeOf(new ReflectProperty(object, property).collectionType.elementType.type);
|
|
51
51
|
const joinTable = [objectTable, propertyTable].sort().join('_');
|
|
52
52
|
const query = 'DELETE FROM `' + joinTable + '` WHERE ' + objectTable + '_id = ? AND ' + propertyTable + '_id = ?';
|
|
53
53
|
const values = [object.id, id];
|
|
@@ -73,7 +73,7 @@ export class Mysql extends DataSource {
|
|
|
73
73
|
async insertRelatedId(object, property, id) {
|
|
74
74
|
const connection = this.connection ?? await this.connect();
|
|
75
75
|
const objectTable = depends.storeOf(object);
|
|
76
|
-
const propertyTable = depends.storeOf(new ReflectProperty(object, property).collectionType.elementType);
|
|
76
|
+
const propertyTable = depends.storeOf(new ReflectProperty(object, property).collectionType.elementType.type);
|
|
77
77
|
const joinTable = [objectTable, propertyTable].sort().join('_');
|
|
78
78
|
const query = 'INSERT INTO `' + joinTable + '` SET ' + objectTable + '_id = ?, ' + propertyTable + '_id = ?';
|
|
79
79
|
const values = [object.id, id];
|
|
@@ -123,7 +123,7 @@ export class Mysql extends DataSource {
|
|
|
123
123
|
const rows = await connection.query('SELECT ' + propertiesSql + ' FROM `' + depends.storeOf(type) + '` WHERE id = ?', [id]);
|
|
124
124
|
return this.valuesFromDb(rows[0], type);
|
|
125
125
|
}
|
|
126
|
-
async readCollection(object, property, type = new ReflectProperty(object, property).collectionType.elementType) {
|
|
126
|
+
async readCollection(object, property, type = new ReflectProperty(object, property).collectionType.elementType.type) {
|
|
127
127
|
const connection = this.connection ?? await this.connect();
|
|
128
128
|
const propertiesSql = this.propertiesToSqlSelect(type);
|
|
129
129
|
const objectTable = depends.storeOf(object);
|
|
@@ -141,7 +141,7 @@ export class Mysql extends DataSource {
|
|
|
141
141
|
const rows = await connection.query(query, [object.id]);
|
|
142
142
|
return Promise.all(rows.map(row => this.valuesFromDb(row, type)));
|
|
143
143
|
}
|
|
144
|
-
async readCollectionIds(object, property, type = new ReflectProperty(object, property).collectionType.elementType) {
|
|
144
|
+
async readCollectionIds(object, property, type = new ReflectProperty(object, property).collectionType.elementType.type) {
|
|
145
145
|
const connection = this.connection ?? await this.connect();
|
|
146
146
|
const objectTable = depends.storeOf(object);
|
|
147
147
|
const propertyTable = depends.storeOf(type);
|
package/package.json
CHANGED