JS wrapper for the QURI string specification
npm install quri
More information about the QURI specification and parser is available here.
import Quri from 'quri';
const quri = new Quri();
quri.toString(); // "field_1".eq("my value")
import Quri from 'quri';
const quri = new Quri();
quri.appendExpression('field_1', '==', 'outer');
const nestedQuri = new Quri('or');
nestedQuri.appendExpression('field_2', 'like', 'nested%');
nestedQuri.appendExpression('field_3', 'in', [1, 2, 3, 4]);
quri.appendCriteria(nestedQuri);
quri.toString();
// "field_1".eq("outer"),("field_2".eq("nested%")|"field_3".in(1,2,3,4))
import Quri from 'quri';
let quri = new Quri();
quri.appendExpression('field_1', '==', 'my value');
quri.serialize();
// { criteria: [ [ 'field_1', '==', 'my value' ] ] }
quri.serialize({ verbose: true });
// { conjunction: 'and', criteria: [ { field: 'field_1', operator: '==', value: 'my value' } ] }
quri.conjunction
// and
quri.criteria
// [ { field: 'field_1', operator: '==', value: 'my value' } ]
quri = Quri.deserialize({ criteria: [ [ 'field_1', '==', 'my value' ] ] })
quri.toString();
// "field_1".eq("my value")
quri = Quri.deserialize({ criteria: [ { field: 'field_1', operator: '==', value: 'my value' } ] });
quri.toString();
// "field_1".eq("my value")
quri = Quri.deserialize({ conjunction: 'or', criteria: [
[ 'field_1', '==', 'my value' ],
[ 'field_2', '==', 'my value 2' ]
] })
quri.toString();
// "field_1".eq("my value")|"field_2".eq("my value 2")
quri = Quri.deserialize({ conjunction: 'or', criteria: [
{ field: 'field_1', operator: '==', value: 'my value' },
{ field: 'field_2', operator: '==', value: 'my value 2' }
] })
quri.toString();
// "field_1".eq("my value")|"field_2".eq("my value 2")
MIT © theHarvester