Skip to content

Commit 624f456

Browse files
Merge pull request #97 from JarvusInnovations/develop
Release: v0.21.6
2 parents 482c949 + 5670962 commit 624f456

File tree

4 files changed

+396
-708
lines changed

4 files changed

+396
-708
lines changed

backend/commands/query.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ exports.builder = {
2828
describe: 'Truncate results to given count',
2929
type: 'number'
3030
},
31-
'filter.<field>': {
31+
'filter': {
32+
group: 'Filtering',
3233
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'
3339
},
3440
fields: {
41+
group: 'Field selection',
3542
describe: 'List of fields to order/limit output columns with',
3643
type: 'array'
3744
},
38-
'fields.<from>': {
39-
describe: 'Fields to remap',
45+
'fields.<from>=<to>': {
46+
group: 'Field selection',
47+
describe: 'Field to remap',
4048
type: 'array'
4149
}
4250
};
@@ -125,11 +133,25 @@ async function* limitResult(result, limit) {
125133
}
126134

127135
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+
128146
for await (const record of result) {
129147
const output = {};
130148

131149
for (const field of fields) {
132-
if (typeof field == 'object') {
150+
if (Array.isArray(field)) {
151+
for (const fieldValue of field) {
152+
output[fieldValue] = record[fieldValue];
153+
}
154+
} else if (typeof field == 'object') {
133155
for (const from in field) {
134156
output[field[from]] = record[from];
135157
}

0 commit comments

Comments
 (0)