@storecraft/database-sql-base 1.0.8 → 1.0.10
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 +11 -1
- package/src/utils.query.js +19 -4
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storecraft/database-sql-base",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.10",
|
4
4
|
"description": "Official SQL Database driver for storecraft",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Tomer Shalev (https://github.com/store-craft)",
|
@@ -19,11 +19,21 @@
|
|
19
19
|
"type": "module",
|
20
20
|
"main": "index.js",
|
21
21
|
"types": "./types.public.d.ts",
|
22
|
+
"exports": {
|
23
|
+
".": {
|
24
|
+
"import": "./index.js",
|
25
|
+
"types": "./types.public.d.ts"
|
26
|
+
},
|
27
|
+
"./*": {
|
28
|
+
"import": "./*"
|
29
|
+
}
|
30
|
+
},
|
22
31
|
"scripts": {
|
23
32
|
"database-sql-base:test:sqlite": "node ./tests/runner.sqlite-local.test.js",
|
24
33
|
"database-sql-base:test:postgres": "node ./tests/runner.postgres-local.test.js",
|
25
34
|
"database-sql-base:test:mysql": "node ./tests/runner.mysql-local.test.js",
|
26
35
|
"test": "npm run database-sql-base:test:sqlite && npm run database-sql-base:test:postgres && npm run database-sql-base:test:mysql",
|
36
|
+
"sc-publish": "npm publish",
|
27
37
|
"prepublishOnly": "npm version patch --force"
|
28
38
|
},
|
29
39
|
"dependencies": {
|
package/src/utils.query.js
CHANGED
@@ -128,6 +128,21 @@ export const query_vql_to_eb = (eb, root, table_name) => {
|
|
128
128
|
}
|
129
129
|
|
130
130
|
|
131
|
+
/**
|
132
|
+
*
|
133
|
+
* @param {[k: string, v: any]} kv
|
134
|
+
* @returns {[k: string, v: any]}
|
135
|
+
*/
|
136
|
+
const transform_boolean_to_0_or_1 = (kv) => {
|
137
|
+
if(typeof kv[1] === 'boolean') {
|
138
|
+
return [
|
139
|
+
kv[0],
|
140
|
+
kv[1] ? 1 : 0
|
141
|
+
]
|
142
|
+
}
|
143
|
+
return kv;
|
144
|
+
}
|
145
|
+
|
131
146
|
/**
|
132
147
|
* Convert an API Query into mongo dialect, also sanitize.
|
133
148
|
*
|
@@ -145,15 +160,15 @@ export const query_to_eb = (eb, q={}, table_name) => {
|
|
145
160
|
|
146
161
|
// compute index clauses
|
147
162
|
if(q.startAt) {
|
148
|
-
clauses.push(query_cursor_to_eb(eb, q.startAt, asc ? '>=' : '<='));
|
163
|
+
clauses.push(query_cursor_to_eb(eb, q.startAt, asc ? '>=' : '<=', transform_boolean_to_0_or_1));
|
149
164
|
} else if(q.startAfter) {
|
150
|
-
clauses.push(query_cursor_to_eb(eb, q.startAfter, asc ? '>' : '<'));
|
165
|
+
clauses.push(query_cursor_to_eb(eb, q.startAfter, asc ? '>' : '<', transform_boolean_to_0_or_1));
|
151
166
|
}
|
152
167
|
|
153
168
|
if(q.endAt) {
|
154
|
-
clauses.push(query_cursor_to_eb(eb, q.endAt, asc ? '<=' : '>='));
|
169
|
+
clauses.push(query_cursor_to_eb(eb, q.endAt, asc ? '<=' : '>=', transform_boolean_to_0_or_1));
|
155
170
|
} else if(q.endBefore) {
|
156
|
-
clauses.push(query_cursor_to_eb(eb, q.endBefore, asc ? '<' : '>'));
|
171
|
+
clauses.push(query_cursor_to_eb(eb, q.endBefore, asc ? '<' : '>', transform_boolean_to_0_or_1));
|
157
172
|
}
|
158
173
|
|
159
174
|
// compute VQL clauses
|