@itrocks/mysql 0.1.1 → 0.1.3

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.js CHANGED
@@ -159,6 +159,8 @@ class Mysql extends storage_1.DataSource {
159
159
  }
160
160
  async query(type, query, values) {
161
161
  const connection = this.connection ?? await this.connect();
162
+ if (exports.DEBUG)
163
+ console.log(query, values);
162
164
  const rows = await connection.query(query, values);
163
165
  return Promise.all(rows.map(row => this.valuesFromDb(row, type)));
164
166
  }
@@ -170,7 +172,8 @@ class Mysql extends storage_1.DataSource {
170
172
  const rows = await connection.query('SELECT ' + propertiesSql + ' FROM `' + depends.storeOf(type) + '` WHERE id = ?', [id]);
171
173
  return this.valuesFromDb(rows[0], type);
172
174
  }
173
- async readCollection(object, property, type = new reflect_2.ReflectProperty(object, property).collectionType.elementType.type) {
175
+ async readCollection(object, property, type) {
176
+ type ??= new reflect_2.ReflectProperty(object, property).collectionType.elementType.type;
174
177
  const connection = this.connection ?? await this.connect();
175
178
  const propertiesSql = this.propertiesToSqlSelect(type);
176
179
  const objectTable = depends.storeOf(object);
@@ -191,7 +194,8 @@ class Mysql extends storage_1.DataSource {
191
194
  const rows = await connection.query(query, [object.id]);
192
195
  return Promise.all(rows.map(row => this.valuesFromDb(row, type)));
193
196
  }
194
- async readCollectionIds(object, property, type = new reflect_2.ReflectProperty(object, property).collectionType.elementType.type) {
197
+ async readCollectionIds(object, property, type) {
198
+ type ??= new reflect_2.ReflectProperty(object, property).collectionType.elementType.type;
195
199
  const connection = this.connection ?? await this.connect();
196
200
  const objectTable = depends.storeOf(object);
197
201
  const propertyTable = depends.storeOf(type);
package/esm/mysql.js CHANGED
@@ -154,6 +154,8 @@ export class Mysql extends DataSource {
154
154
  }
155
155
  async query(type, query, values) {
156
156
  const connection = this.connection ?? await this.connect();
157
+ if (DEBUG)
158
+ console.log(query, values);
157
159
  const rows = await connection.query(query, values);
158
160
  return Promise.all(rows.map(row => this.valuesFromDb(row, type)));
159
161
  }
@@ -165,7 +167,8 @@ export class Mysql extends DataSource {
165
167
  const rows = await connection.query('SELECT ' + propertiesSql + ' FROM `' + depends.storeOf(type) + '` WHERE id = ?', [id]);
166
168
  return this.valuesFromDb(rows[0], type);
167
169
  }
168
- async readCollection(object, property, type = new ReflectProperty(object, property).collectionType.elementType.type) {
170
+ async readCollection(object, property, type) {
171
+ type ??= new ReflectProperty(object, property).collectionType.elementType.type;
169
172
  const connection = this.connection ?? await this.connect();
170
173
  const propertiesSql = this.propertiesToSqlSelect(type);
171
174
  const objectTable = depends.storeOf(object);
@@ -186,7 +189,8 @@ export class Mysql extends DataSource {
186
189
  const rows = await connection.query(query, [object.id]);
187
190
  return Promise.all(rows.map(row => this.valuesFromDb(row, type)));
188
191
  }
189
- async readCollectionIds(object, property, type = new ReflectProperty(object, property).collectionType.elementType.type) {
192
+ async readCollectionIds(object, property, type) {
193
+ type ??= new ReflectProperty(object, property).collectionType.elementType.type;
190
194
  const connection = this.connection ?? await this.connect();
191
195
  const objectTable = depends.storeOf(object);
192
196
  const propertyTable = depends.storeOf(type);
package/package.json CHANGED
@@ -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.1.1"
62
+ "version": "0.1.3"
63
63
  }