mm_mysql 2.5.2 → 2.5.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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/sql.js +20 -0
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "mm_mysql",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "这是超级美眉mysql帮助函数模块,用于便捷操作mysql,使用await方式,可以避免嵌套函数",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
- "mm_expand": "^2.5.1",
8
- "mysql2": "^3.23.2",
7
+ "mm_expand": "^2.5.3",
8
+ "mysql2": "^3.23.3",
9
9
  "sqlstring": "^2.3.3"
10
10
  },
11
11
  "scripts": {
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "eslint": "^10.8.1",
40
- "eslint-plugin-jsdoc": "^64.0.1",
41
- "mm_eslint": "^1.7.5"
40
+ "eslint-plugin-jsdoc": "^64.2.0",
41
+ "mm_eslint": "^1.7.6"
42
42
  }
43
43
  }
package/sql.js CHANGED
@@ -775,6 +775,26 @@ Sql.prototype.getObj = async function (query, sort, view, like, timeout = 20000)
775
775
  return obj;
776
776
  };
777
777
 
778
+ /**
779
+ * 查询数据
780
+ * @param {object} query 查询条件
781
+ * @param {string} sort 排序
782
+ * @param {string} view 返回的字段
783
+ * @param {boolean} like 是否使用like匹配, 为空使用默认方式
784
+ * @param {number} timeout 超时时间(毫秒),默认20000ms
785
+ * @returns {Promise|Array} 查询结果
786
+ */
787
+ Sql.prototype.list = async function (query, sort, view, like, timeout = 20000) {
788
+ if (!this.table) {
789
+ throw new Error('表名未设置');
790
+ }
791
+
792
+ let sql = this.toGetSql(query, sort, view, like);
793
+ this.sql = sql;
794
+ let list = await this.run(sql);
795
+ return list;
796
+ };
797
+
778
798
  /**
779
799
  * 统计记录数
780
800
  * @param {object} query 查询条件