gitsheets 0.21.5 → 0.21.6
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/commands/query.js +26 -4
- package/package.json +3 -3
package/commands/query.js
CHANGED
|
@@ -28,15 +28,23 @@ exports.builder = {
|
|
|
28
28
|
describe: 'Truncate results to given count',
|
|
29
29
|
type: 'number'
|
|
30
30
|
},
|
|
31
|
-
'filter
|
|
31
|
+
'filter': {
|
|
32
|
+
group: 'Filtering',
|
|
32
33
|
describe: 'Filter results by one or more field values',
|
|
34
|
+
type: 'array'
|
|
35
|
+
},
|
|
36
|
+
'filter.<field>[=<value>]': {
|
|
37
|
+
group: 'Filtering',
|
|
38
|
+
describe: 'Field to filter by'
|
|
33
39
|
},
|
|
34
40
|
fields: {
|
|
41
|
+
group: 'Field selection',
|
|
35
42
|
describe: 'List of fields to order/limit output columns with',
|
|
36
43
|
type: 'array'
|
|
37
44
|
},
|
|
38
|
-
'fields.<from>': {
|
|
39
|
-
|
|
45
|
+
'fields.<from>=<to>': {
|
|
46
|
+
group: 'Field selection',
|
|
47
|
+
describe: 'Field to remap',
|
|
40
48
|
type: 'array'
|
|
41
49
|
}
|
|
42
50
|
};
|
|
@@ -125,11 +133,25 @@ async function* limitResult(result, limit) {
|
|
|
125
133
|
}
|
|
126
134
|
|
|
127
135
|
async function* mapResult(result, fields) {
|
|
136
|
+
if (!Array.isArray(fields)) {
|
|
137
|
+
const fieldsObject = fields;
|
|
138
|
+
fields = [];
|
|
139
|
+
for (const fromKey in fieldsObject) {
|
|
140
|
+
const fieldMap = {};
|
|
141
|
+
fieldMap[fromKey] = fieldsObject[fromKey];
|
|
142
|
+
fields.push(fieldMap);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
128
146
|
for await (const record of result) {
|
|
129
147
|
const output = {};
|
|
130
148
|
|
|
131
149
|
for (const field of fields) {
|
|
132
|
-
if (
|
|
150
|
+
if (Array.isArray(field)) {
|
|
151
|
+
for (const fieldValue of field) {
|
|
152
|
+
output[fieldValue] = record[fieldValue];
|
|
153
|
+
}
|
|
154
|
+
} else if (typeof field == 'object') {
|
|
133
155
|
for (const from in field) {
|
|
134
156
|
output[field[from]] = record[from];
|
|
135
157
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitsheets",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.6",
|
|
4
4
|
"description": "A toolkit for using a git repository to store low-volume, high-touch, human-scale data",
|
|
5
5
|
"main": "lib/GitSheets.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"fast-csv": "^4.3.6",
|
|
27
27
|
"fast-json-patch": "^2.2.1",
|
|
28
28
|
"get-stream": "^5.2.0",
|
|
29
|
-
"hologit": "^0.
|
|
29
|
+
"hologit": "^0.41.3",
|
|
30
30
|
"http-assert": "^1.4.1",
|
|
31
31
|
"koa": "^2.13.1",
|
|
32
32
|
"koa-bodyparser": "^4.3.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"tmp": "^0.2.1",
|
|
40
40
|
"to-readable-stream": "^2.1.0",
|
|
41
41
|
"winston": "^3.3.3",
|
|
42
|
-
"yargs": "^
|
|
42
|
+
"yargs": "^17.5.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"common-tags": "^1.8.0",
|