dborm-mysql 2.0.2 → 2.1.0

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/base/dbORM.js CHANGED
@@ -158,23 +158,30 @@ let dbFunss = (config) => {
158
158
  listSql = initSessionSql + ';' + listSql;
159
159
  countSql = initSessionSql + ';' + countSql;
160
160
  }
161
- let list, count;
161
+ let querys = []
162
162
  if(returnFields.includes('list')){
163
- list = await db.query(listSql, listParams, connection).then(res => {
163
+ let list = db.query(listSql, listParams, connection).then(res => {
164
164
  if(initSessionSql){
165
165
  res = res[1];
166
166
  }
167
167
  return dbUtil.convert2RamFieldName(tableName, res);
168
168
  });
169
+ querys.push(list);
170
+ } else {
171
+ querys.push(Promise.resolve(null));
169
172
  }
170
173
  if(returnFields.includes('count')){
171
- count = await db.query(countSql, countParams, connection).then(res => {
174
+ let count = db.query(countSql, countParams, connection).then(res => {
172
175
  if(initSessionSql){
173
176
  res = res[1];
174
177
  }
175
178
  return res[0].count;
176
179
  });
180
+ querys.push(count);
181
+ } else {
182
+ querys.push(Promise.resolve(null));
177
183
  }
184
+ let [list,count] = await Promise.all(querys);
178
185
  return {list, count};
179
186
  };
180
187
 
package/base/dbUtil.js CHANGED
@@ -198,7 +198,7 @@ module.exports = (config, {dbCode = 733, ignoreDataError = false}) => {
198
198
  addFieldNames.push('modify_time');
199
199
  }
200
200
 
201
- let sql = `INSERT INTO ${tableName} (${addFieldNames.map(field => '`' + field + '`').join(',')}) VALUES(?)`;
201
+ let sql = `INSERT INTO ${tableName} (${addFieldNames.join(',')}) VALUES(?)`;
202
202
  let params = addFieldNames.map(fieldName => obj[fieldName]);
203
203
  return {
204
204
  params: [params],
package/index.d.ts CHANGED
@@ -144,9 +144,9 @@ declare namespace dbORM {
144
144
  add(data: any, connection?: mysql.Connection): Promise<number>,
145
145
  delete(data: any, connection?: mysql.Connection): Promise<any>,
146
146
  updateByIds(data: any, ids?: Array<number>, connection?: mysql.Connection): Promise<any>,
147
- update(data: any, id: number | string, connection?: mysql.Connection): Promise<any>,
147
+ update(data: any, id: number, connection?: mysql.Connection): Promise<any>,
148
148
  updateByQuery(data: any, query: any, connection?: mysql.Connection): Promise<any>,
149
- get(id: number | string, connection?: mysql.Connection): Promise<any>,
149
+ get(id: number, connection?: mysql.Connection): Promise<any>,
150
150
  createBulk(objs?: Array<any>, connection?: mysql.Connection): Promise<any>,
151
151
  updateBulk(objs?: Array<any>, connection?: mysql.Connection): Promise<any>,
152
152
  deleteByIds(ids?: Array<number>, connection?: mysql.Connection): Promise<any>,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dborm-mysql",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "a NodeJs ORM for mysql",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",