diff --git a/package.json b/package.json index fb9c305..0710c8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fergies-inverted-index", - "version": "5.2.0", + "version": "5.2.1", "description": "An inverted index that allows javascript objects to be easily serialised and retrieved using promises and map-reduce", "main": "dist/fergies-inverted-index.cjs.js", "module": "dist/fergies-inverted-index.esm.js", diff --git a/src/read.js b/src/read.js index 7a661e0..00019d0 100644 --- a/src/read.js +++ b/src/read.js @@ -7,7 +7,6 @@ export default function init (db, ops) { const parseToken = token => new Promise((resolve, reject) => { // case: // case: : - // case: undefined const setCase = str => ops.caseSensitive ? str : str.toLowerCase() @@ -52,12 +51,14 @@ export default function init (db, ops) { LTE: setCase(token.VALUE) } } + if (typeof token.VALUE === 'undefined') { token.VALUE = { GTE: '!', LTE: '○' } } + token.VALUE = Object.assign(token.VALUE, { GTE: setCase(token.VALUE.GTE || '!'), LTE: setCase(token.VALUE.LTE || '○') @@ -71,8 +72,10 @@ export default function init (db, ops) { }) )) } + // Allow FIELD to be an array or a string token.FIELD = [token.FIELD].flat() + return resolve(token) }) @@ -82,14 +85,15 @@ export default function init (db, ops) { // OR const UNION = (...keys) => Promise.all( - keys.map(key => GET(key)) + keys.map(GET) ).then(sets => { - // flatten - sets = [].concat.apply([], sets) - var setObject = sets.reduce((acc, cur) => { - acc[cur._id] = [...(acc[cur._id] || []), cur._match] - return acc - }, {}) + const setObject = sets.flat(Infinity).reduce( + (acc, cur) => { + acc[cur._id] = [...(acc[cur._id] || []), cur._match] + return acc + }, + {} + ) return Object.keys(setObject).map(id => ({ _id: id, _match: setObject[id] @@ -97,11 +101,10 @@ export default function init (db, ops) { }) // AND - const INTERSECTION = (...keys) => UNION(...keys).then( - result => result.filter( + const INTERSECTION = (...keys) => UNION(...keys) + .then(result => result.filter( item => (item._match.length === keys.length) - ) - ) + )) // NOT (set a minus set b) const SET_SUBTRACTION = (a, b) => Promise.all([ @@ -111,18 +114,18 @@ export default function init (db, ops) { aItem => b.map(bItem => bItem._id).indexOf(aItem._id) === -1) ) - const RANGE = ops => new Promise(resolve => { + const RANGE = token => new Promise(resolve => { const rs = {} // resultset return Promise.all( - ops.FIELD.map( - fieldName => new Promise(resolve => - db.createReadStream({ - gte: fieldName + ':' + ops.VALUE.GTE, - lte: fieldName + ':' + ops.VALUE.LTE + '○' + token.FIELD.map( + fieldName => new Promise(resolve => { + return db.createReadStream({ + gte: fieldName + ':' + token.VALUE.GTE + ops.tokenAppend, + lte: fieldName + ':' + token.VALUE.LTE + ops.tokenAppend + '○' }).on('data', token => token.value.forEach(docId => { rs[docId] = [...(rs[docId] || []), token.key] })).on('end', resolve) - ) + }) ) ).then(() => resolve( // convert map into array @@ -208,17 +211,12 @@ export default function init (db, ops) { }).on('data', resolve) }) - const DIST = ops => new Promise( - resolve => (ops || {}).FIELD - // bump string or Array to Array - ? resolve([ops.FIELD].flat(Infinity)) - : AVAILABLE_FIELDS().then(resolve) - ).then(fields => Promise.all( - fields.map(field => getRange({ - gte: field + ':' + ((ops && ops.VALUE && ops.VALUE.GTE) || ''), - lte: field + ':' + ((ops && ops.VALUE && ops.VALUE.LTE) || '') + '○' + const DIST = token => parseToken(token).then(token => Promise.all( + token.FIELD.map(field => getRange({ + gte: field + ':' + token.VALUE.GTE, + lte: field + ':' + token.VALUE.LTE + '○' }).then(items => items.map(item => ({ - FIELD: [item.split(/:(.+)/)[0]], + FIELD: item.split(/:(.+)/)[0], VALUE: item.split(/:(.+)/)[1] })))) )).then(result => result.flat()) diff --git a/test/cjs/aggregation-test.js b/test/cjs/aggregation-test.js index 6a1ead4..0d92c1e 100644 --- a/test/cjs/aggregation-test.js +++ b/test/cjs/aggregation-test.js @@ -15,7 +15,6 @@ function init (db, ops) { const parseToken = token => new Promise((resolve, reject) => { // case: // case: : - // case: undefined const setCase = str => ops.caseSensitive ? str : str.toLowerCase(); @@ -60,12 +59,14 @@ function init (db, ops) { LTE: setCase(token.VALUE) }; } + if (typeof token.VALUE === 'undefined') { token.VALUE = { GTE: '!', LTE: '○' }; } + token.VALUE = Object.assign(token.VALUE, { GTE: setCase(token.VALUE.GTE || '!'), LTE: setCase(token.VALUE.LTE || '○') @@ -92,7 +93,7 @@ function init (db, ops) { // OR const UNION = (...keys) => Promise.all( - keys.map(key => GET(key)) + keys.map(GET) ).then(sets => { const setObject = sets.flat(Infinity).reduce( (acc, cur) => { @@ -108,11 +109,10 @@ function init (db, ops) { }); // AND - const INTERSECTION = (...keys) => UNION(...keys).then( - result => result.filter( + const INTERSECTION = (...keys) => UNION(...keys) + .then(result => result.filter( item => (item._match.length === keys.length) - ) - ); + )); // NOT (set a minus set b) const SET_SUBTRACTION = (a, b) => Promise.all([ @@ -122,19 +122,18 @@ function init (db, ops) { aItem => b.map(bItem => bItem._id).indexOf(aItem._id) === -1) ); - - const RANGE = ops => new Promise(resolve => { - const rs = {}; // resultset + const RANGE = token => new Promise(resolve => { + const rs = {}; // resultset return Promise.all( - ops.FIELD.map( - fieldName => new Promise(resolve => - db.createReadStream({ - gte: fieldName + ':' + ops.VALUE.GTE, - lte: fieldName + ':' + ops.VALUE.LTE + '○' + token.FIELD.map( + fieldName => new Promise(resolve => { + return db.createReadStream({ + gte: fieldName + ':' + token.VALUE.GTE + ops.tokenAppend, + lte: fieldName + ':' + token.VALUE.LTE + ops.tokenAppend + '○' }).on('data', token => token.value.forEach(docId => { rs[docId] = [...(rs[docId] || []), token.key]; })).on('end', resolve) - ) + }) ) ).then(() => resolve( // convert map into array @@ -144,7 +143,7 @@ function init (db, ops) { })) )) }); - + const AVAILABLE_FIELDS = () => new Promise(resolve => { const fieldNames = []; db.createReadStream({ @@ -188,7 +187,7 @@ function init (db, ops) { }) }) ); - + const OBJECT = _ids => Promise.all( _ids.map( id => db.get('○DOC○' + id._id + '○').catch(reason => null) @@ -220,21 +219,16 @@ function init (db, ops) { }).on('data', resolve); }); - const DIST = ops => new Promise( - resolve => (ops || {}).FIELD - // bump string or Array to Array - ? resolve([ops.FIELD].flat(Infinity)) - : AVAILABLE_FIELDS().then(resolve) - ).then(fields => Promise.all( - fields.map(field => getRange({ - gte: field + ':' + ((ops && ops.VALUE && ops.VALUE.GTE) || ''), - lte: field + ':' + ((ops && ops.VALUE && ops.VALUE.LTE) || '') + '○' + const DIST = token => parseToken(token).then(token => Promise.all( + token.FIELD.map(field => getRange({ + gte: field + ':' + token.VALUE.GTE, + lte: field + ':' + token.VALUE.LTE + '○' }).then(items => items.map(item => ({ - FIELD: [ item.split(/:(.+)/)[0] ], + FIELD: item.split(/:(.+)/)[0], VALUE: item.split(/:(.+)/)[1] })))) )).then(result => result.flat()); - + return { FIELDS: AVAILABLE_FIELDS, BUCKET: BUCKET, @@ -612,11 +606,11 @@ test('can GET a single bucket with gte LTE', t => { test('can get DISTINCT values', t => { t.plan(1); global[indexName].DISTINCT({ - FIELD:'make' + FIELD: 'make' }).then(result => t.deepEquals(result, [ - { FIELD: [ 'make' ], VALUE: 'BMW' }, - { FIELD: [ 'make' ], VALUE: 'Tesla' }, - { FIELD: [ 'make' ], VALUE: 'Volvo' } + { FIELD: 'make', VALUE: 'BMW' }, + { FIELD: 'make', VALUE: 'Tesla' }, + { FIELD: 'make', VALUE: 'Volvo' } ])); }); @@ -628,8 +622,8 @@ test('can get DISTINCT values with gte', t => { GTE: 'C' } }).then(result => t.deepEquals(result, [ - { FIELD: [ 'make' ], VALUE: 'Tesla' }, - { FIELD: [ 'make' ], VALUE: 'Volvo' } + { FIELD: 'make', VALUE: 'Tesla' }, + { FIELD: 'make', VALUE: 'Volvo' } ])); }); @@ -642,7 +636,7 @@ test('can get DISTINCT VALUEs with GTE and LTE', t => { LTE: 'U' } }).then(result => t.deepEquals(result, [ - { FIELD: [ 'make' ], VALUE: 'Tesla' } + { FIELD: 'make', VALUE: 'Tesla' } ])); }); diff --git a/test/src/DISTINCT-test.js b/test/src/DISTINCT-test.js index 5ccefa9..80b771c 100644 --- a/test/src/DISTINCT-test.js +++ b/test/src/DISTINCT-test.js @@ -115,10 +115,10 @@ test('get DISTINCT values for one field', t => { global[indexName].DISTINCT({ FIELD: 'drivetrain' }).then(result => t.deepEqual(result, [ - { FIELD: [ 'drivetrain' ], VALUE: 'Diesel' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Electric' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Hybrid' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Petrol' } + { FIELD: 'drivetrain', VALUE: 'Diesel' }, + { FIELD: 'drivetrain', VALUE: 'Electric' }, + { FIELD: 'drivetrain', VALUE: 'Hybrid' }, + { FIELD: 'drivetrain', VALUE: 'Petrol' } ])) }) @@ -127,13 +127,13 @@ test('get DISTINCT values for two fields', t => { global[indexName].DISTINCT({ FIELD: [ 'drivetrain', 'make' ] }).then(result => t.deepEqual(result, [ - { FIELD: [ 'drivetrain' ], VALUE: 'Diesel' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Electric' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Hybrid' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Petrol' }, - { FIELD: [ 'make' ], VALUE: 'BMW' }, - { FIELD: [ 'make' ], VALUE: 'Tesla' }, - { FIELD: [ 'make' ], VALUE: 'Volvo' } + { FIELD: 'drivetrain', VALUE: 'Diesel' }, + { FIELD: 'drivetrain', VALUE: 'Electric' }, + { FIELD: 'drivetrain', VALUE: 'Hybrid' }, + { FIELD: 'drivetrain', VALUE: 'Petrol' }, + { FIELD: 'make', VALUE: 'BMW' }, + { FIELD: 'make', VALUE: 'Tesla' }, + { FIELD: 'make', VALUE: 'Volvo' } ])) }) @@ -142,106 +142,106 @@ test('get DISTINCT values for three fields', t => { global[indexName].DISTINCT({ FIELD: [ 'drivetrain', 'make', 'colour' ] }).then(result => t.deepEqual(result, [ - { FIELD: [ 'drivetrain' ], VALUE: 'Diesel' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Electric' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Hybrid' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Petrol' }, - { FIELD: [ 'make' ], VALUE: 'BMW' }, - { FIELD: [ 'make' ], VALUE: 'Tesla' }, - { FIELD: [ 'make' ], VALUE: 'Volvo' }, - { FIELD: [ 'colour' ], VALUE: 'Black' }, - { FIELD: [ 'colour' ], VALUE: 'Blue' }, - { FIELD: [ 'colour' ], VALUE: 'Red' }, - { FIELD: [ 'colour' ], VALUE: 'Silver' }, - { FIELD: [ 'colour' ], VALUE: 'White' } + { FIELD: 'drivetrain', VALUE: 'Diesel' }, + { FIELD: 'drivetrain', VALUE: 'Electric' }, + { FIELD: 'drivetrain', VALUE: 'Hybrid' }, + { FIELD: 'drivetrain', VALUE: 'Petrol' }, + { FIELD: 'make', VALUE: 'BMW' }, + { FIELD: 'make', VALUE: 'Tesla' }, + { FIELD: 'make', VALUE: 'Volvo' }, + { FIELD: 'colour', VALUE: 'Black' }, + { FIELD: 'colour', VALUE: 'Blue' }, + { FIELD: 'colour', VALUE: 'Red' }, + { FIELD: 'colour', VALUE: 'Silver' }, + { FIELD: 'colour', VALUE: 'White' } ])) }) test('get DISTINCT values for ALL fields using {}', t => { t.plan(1) global[indexName].DISTINCT({}).then(result => t.deepEqual(result, [ - { FIELD: [ 'colour' ], VALUE: 'Black' }, - { FIELD: [ 'colour' ], VALUE: 'Blue' }, - { FIELD: [ 'colour' ], VALUE: 'Red' }, - { FIELD: [ 'colour' ], VALUE: 'Silver' }, - { FIELD: [ 'colour' ], VALUE: 'White' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Diesel' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Electric' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Hybrid' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Petrol' }, - { FIELD: [ 'make' ], VALUE: 'BMW' }, - { FIELD: [ 'make' ], VALUE: 'Tesla' }, - { FIELD: [ 'make' ], VALUE: 'Volvo' }, - { FIELD: [ 'model' ], VALUE: '3-series' }, - { FIELD: [ 'model' ], VALUE: '5-series' }, - { FIELD: [ 'model' ], VALUE: 'S' }, - { FIELD: [ 'model' ], VALUE: 'X' }, - { FIELD: [ 'model' ], VALUE: 'XC60' }, - { FIELD: [ 'model' ], VALUE: 'XC90' }, - { FIELD: [ 'price' ], VALUE: '33114' }, - { FIELD: [ 'price' ], VALUE: '37512' }, - { FIELD: [ 'price' ], VALUE: '44274' }, - { FIELD: [ 'price' ], VALUE: '47391' }, - { FIELD: [ 'price' ], VALUE: '57280' }, - { FIELD: [ 'price' ], VALUE: '75397' }, - { FIELD: [ 'price' ], VALUE: '79540' }, - { FIELD: [ 'price' ], VALUE: '81177' }, - { FIELD: [ 'price' ], VALUE: '83988' }, - { FIELD: [ 'price' ], VALUE: '88652' }, - { FIELD: [ 'year' ], VALUE: '2000' }, - { FIELD: [ 'year' ], VALUE: '2004' }, - { FIELD: [ 'year' ], VALUE: '2007' }, - { FIELD: [ 'year' ], VALUE: '2008' }, - { FIELD: [ 'year' ], VALUE: '2011' }, - { FIELD: [ 'year' ], VALUE: '2014' }, - { FIELD: [ 'year' ], VALUE: '2015' }, - { FIELD: [ 'year' ], VALUE: '2016' }, - { FIELD: [ 'year' ], VALUE: '2017' }, - { FIELD: [ 'year' ], VALUE: '2019' } + { FIELD: 'colour', VALUE: 'Black' }, + { FIELD: 'colour', VALUE: 'Blue' }, + { FIELD: 'colour', VALUE: 'Red' }, + { FIELD: 'colour', VALUE: 'Silver' }, + { FIELD: 'colour', VALUE: 'White' }, + { FIELD: 'drivetrain', VALUE: 'Diesel' }, + { FIELD: 'drivetrain', VALUE: 'Electric' }, + { FIELD: 'drivetrain', VALUE: 'Hybrid' }, + { FIELD: 'drivetrain', VALUE: 'Petrol' }, + { FIELD: 'make', VALUE: 'BMW' }, + { FIELD: 'make', VALUE: 'Tesla' }, + { FIELD: 'make', VALUE: 'Volvo' }, + { FIELD: 'model', VALUE: '3-series' }, + { FIELD: 'model', VALUE: '5-series' }, + { FIELD: 'model', VALUE: 'S' }, + { FIELD: 'model', VALUE: 'X' }, + { FIELD: 'model', VALUE: 'XC60' }, + { FIELD: 'model', VALUE: 'XC90' }, + { FIELD: 'price', VALUE: '33114' }, + { FIELD: 'price', VALUE: '37512' }, + { FIELD: 'price', VALUE: '44274' }, + { FIELD: 'price', VALUE: '47391' }, + { FIELD: 'price', VALUE: '57280' }, + { FIELD: 'price', VALUE: '75397' }, + { FIELD: 'price', VALUE: '79540' }, + { FIELD: 'price', VALUE: '81177' }, + { FIELD: 'price', VALUE: '83988' }, + { FIELD: 'price', VALUE: '88652' }, + { FIELD: 'year', VALUE: '2000' }, + { FIELD: 'year', VALUE: '2004' }, + { FIELD: 'year', VALUE: '2007' }, + { FIELD: 'year', VALUE: '2008' }, + { FIELD: 'year', VALUE: '2011' }, + { FIELD: 'year', VALUE: '2014' }, + { FIELD: 'year', VALUE: '2015' }, + { FIELD: 'year', VALUE: '2016' }, + { FIELD: 'year', VALUE: '2017' }, + { FIELD: 'year', VALUE: '2019' } ])) }) test('get DISTINCT values for ALL fields using no param (DISTINCT())', t => { t.plan(1) global[indexName].DISTINCT().then(result => t.deepEqual(result, [ - { FIELD: [ 'colour' ], VALUE: 'Black' }, - { FIELD: [ 'colour' ], VALUE: 'Blue' }, - { FIELD: [ 'colour' ], VALUE: 'Red' }, - { FIELD: [ 'colour' ], VALUE: 'Silver' }, - { FIELD: [ 'colour' ], VALUE: 'White' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Diesel' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Electric' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Hybrid' }, - { FIELD: [ 'drivetrain' ], VALUE: 'Petrol' }, - { FIELD: [ 'make' ], VALUE: 'BMW' }, - { FIELD: [ 'make' ], VALUE: 'Tesla' }, - { FIELD: [ 'make' ], VALUE: 'Volvo' }, - { FIELD: [ 'model' ], VALUE: '3-series' }, - { FIELD: [ 'model' ], VALUE: '5-series' }, - { FIELD: [ 'model' ], VALUE: 'S' }, - { FIELD: [ 'model' ], VALUE: 'X' }, - { FIELD: [ 'model' ], VALUE: 'XC60' }, - { FIELD: [ 'model' ], VALUE: 'XC90' }, - { FIELD: [ 'price' ], VALUE: '33114' }, - { FIELD: [ 'price' ], VALUE: '37512' }, - { FIELD: [ 'price' ], VALUE: '44274' }, - { FIELD: [ 'price' ], VALUE: '47391' }, - { FIELD: [ 'price' ], VALUE: '57280' }, - { FIELD: [ 'price' ], VALUE: '75397' }, - { FIELD: [ 'price' ], VALUE: '79540' }, - { FIELD: [ 'price' ], VALUE: '81177' }, - { FIELD: [ 'price' ], VALUE: '83988' }, - { FIELD: [ 'price' ], VALUE: '88652' }, - { FIELD: [ 'year' ], VALUE: '2000' }, - { FIELD: [ 'year' ], VALUE: '2004' }, - { FIELD: [ 'year' ], VALUE: '2007' }, - { FIELD: [ 'year' ], VALUE: '2008' }, - { FIELD: [ 'year' ], VALUE: '2011' }, - { FIELD: [ 'year' ], VALUE: '2014' }, - { FIELD: [ 'year' ], VALUE: '2015' }, - { FIELD: [ 'year' ], VALUE: '2016' }, - { FIELD: [ 'year' ], VALUE: '2017' }, - { FIELD: [ 'year' ], VALUE: '2019' } + { FIELD: 'colour', VALUE: 'Black' }, + { FIELD: 'colour', VALUE: 'Blue' }, + { FIELD: 'colour', VALUE: 'Red' }, + { FIELD: 'colour', VALUE: 'Silver' }, + { FIELD: 'colour', VALUE: 'White' }, + { FIELD: 'drivetrain', VALUE: 'Diesel' }, + { FIELD: 'drivetrain', VALUE: 'Electric' }, + { FIELD: 'drivetrain', VALUE: 'Hybrid' }, + { FIELD: 'drivetrain', VALUE: 'Petrol' }, + { FIELD: 'make', VALUE: 'BMW' }, + { FIELD: 'make', VALUE: 'Tesla' }, + { FIELD: 'make', VALUE: 'Volvo' }, + { FIELD: 'model', VALUE: '3-series' }, + { FIELD: 'model', VALUE: '5-series' }, + { FIELD: 'model', VALUE: 'S' }, + { FIELD: 'model', VALUE: 'X' }, + { FIELD: 'model', VALUE: 'XC60' }, + { FIELD: 'model', VALUE: 'XC90' }, + { FIELD: 'price', VALUE: '33114' }, + { FIELD: 'price', VALUE: '37512' }, + { FIELD: 'price', VALUE: '44274' }, + { FIELD: 'price', VALUE: '47391' }, + { FIELD: 'price', VALUE: '57280' }, + { FIELD: 'price', VALUE: '75397' }, + { FIELD: 'price', VALUE: '79540' }, + { FIELD: 'price', VALUE: '81177' }, + { FIELD: 'price', VALUE: '83988' }, + { FIELD: 'price', VALUE: '88652' }, + { FIELD: 'year', VALUE: '2000' }, + { FIELD: 'year', VALUE: '2004' }, + { FIELD: 'year', VALUE: '2007' }, + { FIELD: 'year', VALUE: '2008' }, + { FIELD: 'year', VALUE: '2011' }, + { FIELD: 'year', VALUE: '2014' }, + { FIELD: 'year', VALUE: '2015' }, + { FIELD: 'year', VALUE: '2016' }, + { FIELD: 'year', VALUE: '2017' }, + { FIELD: 'year', VALUE: '2019' } ])) }) diff --git a/test/src/aggregation-test.js b/test/src/aggregation-test.js index 57da9ec..694a438 100644 --- a/test/src/aggregation-test.js +++ b/test/src/aggregation-test.js @@ -150,11 +150,11 @@ test('can GET a single bucket with gte LTE', t => { test('can get DISTINCT values', t => { t.plan(1) global[indexName].DISTINCT({ - FIELD:'make' + FIELD: 'make' }).then(result => t.deepEquals(result, [ - { FIELD: [ 'make' ], VALUE: 'BMW' }, - { FIELD: [ 'make' ], VALUE: 'Tesla' }, - { FIELD: [ 'make' ], VALUE: 'Volvo' } + { FIELD: 'make', VALUE: 'BMW' }, + { FIELD: 'make', VALUE: 'Tesla' }, + { FIELD: 'make', VALUE: 'Volvo' } ])) }) @@ -166,8 +166,8 @@ test('can get DISTINCT values with gte', t => { GTE: 'C' } }).then(result => t.deepEquals(result, [ - { FIELD: [ 'make' ], VALUE: 'Tesla' }, - { FIELD: [ 'make' ], VALUE: 'Volvo' } + { FIELD: 'make', VALUE: 'Tesla' }, + { FIELD: 'make', VALUE: 'Volvo' } ])) }) @@ -180,7 +180,7 @@ test('can get DISTINCT VALUEs with GTE and LTE', t => { LTE: 'U' } }).then(result => t.deepEquals(result, [ - { FIELD: [ 'make' ], VALUE: 'Tesla' } + { FIELD: 'make', VALUE: 'Tesla' } ])) }) diff --git a/test/src/query-parser-test.js b/test/src/query-parser-test.js index c68ac1d..975a710 100644 --- a/test/src/query-parser-test.js +++ b/test/src/query-parser-test.js @@ -282,14 +282,14 @@ test('can get all VALUEs of totalamt (DIST)', t => { }) .then(result => { t.deepEqual(result, [ - { FIELD: [ 'totalamt' ], VALUE: '0' }, - { FIELD: [ 'totalamt' ], VALUE: '10000000' }, - { FIELD: [ 'totalamt' ], VALUE: '130000000' }, - { FIELD: [ 'totalamt' ], VALUE: '13100000' }, - { FIELD: [ 'totalamt' ], VALUE: '160000000' }, - { FIELD: [ 'totalamt' ], VALUE: '200000000' }, - { FIELD: [ 'totalamt' ], VALUE: '500000000' }, - { FIELD: [ 'totalamt' ], VALUE: '6060000' } + { FIELD: 'totalamt', VALUE: '0' }, + { FIELD: 'totalamt', VALUE: '10000000' }, + { FIELD: 'totalamt', VALUE: '130000000' }, + { FIELD: 'totalamt', VALUE: '13100000' }, + { FIELD: 'totalamt', VALUE: '160000000' }, + { FIELD: 'totalamt', VALUE: '200000000' }, + { FIELD: 'totalamt', VALUE: '500000000' }, + { FIELD: 'totalamt', VALUE: '6060000' } ]) }) })