doix-db 1.0.37 → 1.0.38
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.js +6 -1
- package/lib/query/DbQueryBinary.js +35 -0
- package/lib/query/DbQueryNot.js +23 -0
- package/package.json +1 -1
- package/lib/query/DbQueryOr.js +0 -33
package/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const DbQueryBinary = require ('./lib/query/DbQueryBinary.js')
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
|
|
3
5
|
DbCallTracker : require ('./lib/DbCallTracker.js'),
|
|
@@ -31,7 +33,10 @@ module.exports = {
|
|
|
31
33
|
DbQuery: require ('./lib/query/DbQuery.js'),
|
|
32
34
|
DbQueryTable: require ('./lib/query/DbQueryTable.js'),
|
|
33
35
|
DbQueryColumn: require ('./lib/query/DbQueryColumn.js'),
|
|
34
|
-
|
|
36
|
+
DbQueryNot: require ('./lib/query/DbQueryNot.js'),
|
|
37
|
+
DbQueryOr: DbQueryBinary ('OR'),
|
|
38
|
+
DbQueryAnd: DbQueryBinary ('AND'),
|
|
39
|
+
|
|
35
40
|
DbQueryTableColumnComparison: require ('./lib/query/DbQueryTableColumnComparison.js'),
|
|
36
41
|
|
|
37
42
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module.exports = op => (
|
|
2
|
+
|
|
3
|
+
class {
|
|
4
|
+
|
|
5
|
+
constructor (filters = []) {
|
|
6
|
+
|
|
7
|
+
this.filters = filters
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
get sql () {
|
|
12
|
+
|
|
13
|
+
const {filters} = this; if (filters.length === 0) throw Error ('No one term in this search condition')
|
|
14
|
+
|
|
15
|
+
return '(' + filters.map (i => '(' + i.sql + ')').join (' ' + op + ' ') + ')'
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get params () {
|
|
20
|
+
|
|
21
|
+
let a = []
|
|
22
|
+
|
|
23
|
+
for (const {params} of this.filters)
|
|
24
|
+
|
|
25
|
+
if (Array.isArray (params))
|
|
26
|
+
|
|
27
|
+
a = a.concat (params)
|
|
28
|
+
|
|
29
|
+
return a
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
)
|
package/package.json
CHANGED
package/lib/query/DbQueryOr.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
class DbQueryOr {
|
|
2
|
-
|
|
3
|
-
constructor (filters = []) {
|
|
4
|
-
|
|
5
|
-
this.filters = filters
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
get sql () {
|
|
10
|
-
|
|
11
|
-
const {filters} = this; if (filters.length === 0) throw Error ('No one term in this search condition')
|
|
12
|
-
|
|
13
|
-
return '(' + filters.map (i => '(' + i.sql + ')').join (' OR ') + ')'
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
get params () {
|
|
18
|
-
|
|
19
|
-
let a = []
|
|
20
|
-
|
|
21
|
-
for (const {params} of this.filters)
|
|
22
|
-
|
|
23
|
-
if (Array.isArray (params))
|
|
24
|
-
|
|
25
|
-
a = a.concat (params)
|
|
26
|
-
|
|
27
|
-
return a
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
module.exports = DbQueryOr
|