@kubun/db 0.3.3 → 0.3.4
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/lib/query-builder.js +11 -0
- package/package.json +3 -3
package/lib/query-builder.js
CHANGED
|
@@ -199,6 +199,10 @@ export function applyDocumentOrderBy(queryBuilder, orderBy = [], isReverse = fal
|
|
|
199
199
|
paths
|
|
200
200
|
];
|
|
201
201
|
}
|
|
202
|
+
const KNOWN_FIELDS = {
|
|
203
|
+
_createdAt: 'created_at',
|
|
204
|
+
_owner: 'owner'
|
|
205
|
+
};
|
|
202
206
|
function applyOrderByField(query, orderBy, isReverse, path = []) {
|
|
203
207
|
const entries = Object.entries(orderBy);
|
|
204
208
|
if (entries.length !== 1) {
|
|
@@ -209,6 +213,13 @@ function applyOrderByField(query, orderBy, isReverse, path = []) {
|
|
|
209
213
|
...path,
|
|
210
214
|
key
|
|
211
215
|
];
|
|
216
|
+
const knowField = KNOWN_FIELDS[key];
|
|
217
|
+
if (knowField != null) {
|
|
218
|
+
return [
|
|
219
|
+
query.orderBy(knowField, orderByDirection(value, isReverse)),
|
|
220
|
+
keys
|
|
221
|
+
];
|
|
222
|
+
}
|
|
212
223
|
return typeof value === 'string' ? [
|
|
213
224
|
query.orderBy((eb)=>getKeyPath(eb, keys), orderByDirection(value, isReverse)),
|
|
214
225
|
keys
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/db",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"license": "see LICENSE.md",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"type": "module",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"kysely": "^0.28.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
+
"@kubun/db-adapter": "^0.3.2",
|
|
23
24
|
"@kubun/id": "^0.3.0",
|
|
24
|
-
"@kubun/protocol": "^0.3.4"
|
|
25
|
-
"@kubun/db-adapter": "^0.3.2"
|
|
25
|
+
"@kubun/protocol": "^0.3.4"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build:clean": "del lib",
|