@axiosleo/orm-mysql 0.6.3 → 0.7.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/index.d.ts CHANGED
@@ -79,6 +79,8 @@ export declare class Query {
79
79
 
80
80
  whereConditions(...condition: WhereOptions[]): this;
81
81
 
82
+ groupWhere(...condition: WhereOptions[]): this;
83
+
82
84
  orWhere(key: string | null, opt: OptType, value: ConditionValueType | WhereOptions[]): this;
83
85
 
84
86
  andWhere(key: string | null, opt: OptType, value: ConditionValueType | WhereOptions[]): this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiosleo/orm-mysql",
3
- "version": "0.6.3",
3
+ "version": "0.7.0",
4
4
  "description": "MySQL ORM tool",
5
5
  "keywords": [
6
6
  "mysql",
package/src/builder.js CHANGED
@@ -216,6 +216,12 @@ class Builder {
216
216
  let sql = typeof prefix === 'undefined' ? 'WHERE ' : prefix;
217
217
  if (conditions.length) {
218
218
  sql += `${conditions.map((c) => {
219
+ if (typeof c.key === 'undefined') {
220
+ c.key = null;
221
+ }
222
+ if (typeof c.value === 'undefined') {
223
+ c.value = null;
224
+ }
219
225
  if (c.key === null && c.value === null) {
220
226
  return ` ${c.opt} `;
221
227
  }
package/src/query.js CHANGED
@@ -69,6 +69,18 @@ class Query {
69
69
  return this;
70
70
  }
71
71
 
72
+ groupWhere(...conditions) {
73
+ if (!conditions.length) {
74
+ return this;
75
+ }
76
+ const condition = { key: null, opt: 'group', value: [] };
77
+ conditions.forEach((c) => {
78
+ condition.value.push(c);
79
+ });
80
+ this.options.conditions.push(condition);
81
+ return this;
82
+ }
83
+
72
84
  orWhere(key, opt, value) {
73
85
  if (!this.options.conditions.length) {
74
86
  throw new Error('At least one where condition is required');