diff --git a/.travis.yml b/.travis.yml
index 2c87fd2..6595b82 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,7 +9,6 @@ notifications:
node_js:
- 10
before_install:
- - sudo apt-get update
- sudo apt-get install expect
- sudo apt-get install libnotify-bin
install:
diff --git a/README.md b/README.md
index 9afaf4f..b9ba0e9 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
---
-[](https://travis-ci.org/bullhorn/taurus)
+[](https://travis-ci.com/bullhorn/taurus)
[](https://dependencyci.com/github/bullhorn/taurus)
[](https://github.com/sindresorhus/xo)
[](https://badge.fury.io/js/%40bullhorn%2Ftaurus)
diff --git a/docs/index.html b/docs/index.html
index e8a0787..2dae857 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -69,7 +69,7 @@
+

Website • Docs • Blog
diff --git a/src/services/Where.ts b/src/services/Where.ts
index 30d607c..e21c2d6 100644
--- a/src/services/Where.ts
+++ b/src/services/Where.ts
@@ -120,6 +120,10 @@ export class Where {
const value = data[key];
if (key === 'or') {
queries.push(`(${Where.toQuerySyntax(value).replace(/ AND /g, ' OR ')})`);
+ } else if (key === 'groupedOr' && Array.isArray(value) && value.length > 0) {
+ queries.push(`(${value.map((group) => {
+ return `(${Where.toQuerySyntax(group)})`;
+ }).join(' OR ')})`);
} else if (key === 'orMinMax') {
for (const subkey of Object.keys(value)) {
queries.push(`(${Where.parseQueryValue(subkey, value[subkey])})`);
diff --git a/test/Where.spec.ts b/test/Where.spec.ts
index d2ab6a6..ac4beb5 100644
--- a/test/Where.spec.ts
+++ b/test/Where.spec.ts
@@ -110,6 +110,43 @@ describe('Where', () => {
});
});
+ describe('with groupedOr queries', () => {
+ it('should create a valid grouped OR query', () => {
+ const where = Where.toQuerySyntax({
+ title: 'Mr. President',
+ groupedOr: [{
+ firstName: 'Abe',
+ lastName: 'Lincoln',
+ }, {
+ owner: {
+ firstName: 'Abe',
+ lastName: 'Lincoln',
+ },
+ }]
+ });
+
+ expect(where).toEqual("title='Mr. President' AND ((firstName='Abe' AND lastName='Lincoln') OR (owner.firstName='Abe' AND owner.lastName='Lincoln'))");
+ });
+ it('should create a valid OR query with 3 or more grouped or conditions', () => {
+ const where = Where.toQuerySyntax({
+ groupedOr: [{
+ firstName: 'Abe',
+ lastName: 'Lincoln',
+ title: 'Mr. President',
+ }, {
+ owner: {
+ firstName: 'Abe',
+ lastName: 'Lincoln',
+ },
+ }, {
+ externalID: 'testID',
+ }]
+ });
+
+ expect(where).toEqual("((firstName='Abe' AND lastName='Lincoln' AND title='Mr. President') OR (owner.firstName='Abe' AND owner.lastName='Lincoln') OR (externalID='testID'))");
+ });
+ });
+
describe('with OR min/max queries', () => {
it('should create a valid nested OR min/max query', () => {
const where = Where.toQuerySyntax({