mm_mysql 2.4.9 → 2.5.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.
Files changed (2) hide show
  1. package/index.js +18 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -433,6 +433,24 @@ Mysql.prototype.db = function () {
433
433
  return new DB(this);
434
434
  };
435
435
 
436
+ /**
437
+ * 获取表管理器(语法糖,等同于 db().new(name, key))
438
+ * @param {string} name 表名
439
+ * @param {string} key 主键字段名
440
+ * @returns {object} DB表管理器实例
441
+ */
442
+ Mysql.prototype.table = function (name, key) {
443
+ if (typeof name !== 'string' || name.trim() === '') {
444
+ throw new TypeError('name must be non-empty string');
445
+ }
446
+ var db = this.db();
447
+ db.table = name;
448
+ if (key) {
449
+ db.key = key;
450
+ }
451
+ return db;
452
+ };
453
+
436
454
  /**
437
455
  * 初始化MySQL服务(保持兼容性)
438
456
  * @returns {Promise<void>}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_mysql",
3
- "version": "2.4.9",
3
+ "version": "2.5.0",
4
4
  "description": "这是超级美眉mysql帮助函数模块,用于便捷操作mysql,使用await方式,可以避免嵌套函数",
5
5
  "main": "index.js",
6
6
  "dependencies": {