@ihago.santos/fluentsql 1.0.0 → 1.0.1
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/package.json +1 -1
- package/src/fluentSQL.js +5 -10
package/package.json
CHANGED
package/src/fluentSQL.js
CHANGED
|
@@ -12,11 +12,13 @@ export default class FluentSQLBuilder {
|
|
|
12
12
|
static for(database) {
|
|
13
13
|
return new FluentSQLBuilder({ database })
|
|
14
14
|
}
|
|
15
|
+
|
|
15
16
|
limit(max) {
|
|
16
17
|
this.#limit = max
|
|
17
18
|
|
|
18
19
|
return this
|
|
19
20
|
}
|
|
21
|
+
|
|
20
22
|
select(props) {
|
|
21
23
|
this.#select = props
|
|
22
24
|
|
|
@@ -24,21 +26,11 @@ export default class FluentSQLBuilder {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
where(query) {
|
|
27
|
-
// {category: 'developer'}
|
|
28
|
-
// {category: /dev/}
|
|
29
|
-
|
|
30
|
-
|
|
31
29
|
const [[prop, selectedValue]] = Object.entries(query)
|
|
32
30
|
const whereFilter = selectedValue instanceof RegExp ?
|
|
33
31
|
selectedValue :
|
|
34
32
|
new RegExp(selectedValue)
|
|
35
33
|
|
|
36
|
-
/*
|
|
37
|
-
[
|
|
38
|
-
[category, 'developer']
|
|
39
|
-
]
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
34
|
this.#where.push({ prop, filter: whereFilter})
|
|
43
35
|
|
|
44
36
|
return this
|
|
@@ -49,6 +41,7 @@ export default class FluentSQLBuilder {
|
|
|
49
41
|
|
|
50
42
|
return this
|
|
51
43
|
}
|
|
44
|
+
|
|
52
45
|
#performLimit(results) {
|
|
53
46
|
return this.#limit && results.length === this.#limit
|
|
54
47
|
}
|
|
@@ -60,6 +53,7 @@ export default class FluentSQLBuilder {
|
|
|
60
53
|
|
|
61
54
|
return true
|
|
62
55
|
}
|
|
56
|
+
|
|
63
57
|
#performSelect(item) {
|
|
64
58
|
const currentItem = {}
|
|
65
59
|
const entries = Object.entries(item)
|
|
@@ -71,6 +65,7 @@ export default class FluentSQLBuilder {
|
|
|
71
65
|
|
|
72
66
|
return currentItem
|
|
73
67
|
}
|
|
68
|
+
|
|
74
69
|
#performOrderBy(results) {
|
|
75
70
|
|
|
76
71
|
if(!this.#orderBy) return results
|