@vepler/property-query-builder
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -60,2 +60,7 @@ import { Condition, Operator, Query } from './query-builder-types'; | ||
/** | ||
* Retrieves an array of unique filter fields used in the current query. | ||
* @returns An array of unique filter fields. | ||
*/ | ||
getUniqueFilterFields(): string[]; | ||
/** | ||
* Retrieves the constructed query. | ||
@@ -62,0 +67,0 @@ * @returns The constructed query. |
@@ -123,2 +123,20 @@ "use strict"; | ||
/** | ||
* Retrieves an array of unique filter fields used in the current query. | ||
* @returns An array of unique filter fields. | ||
*/ | ||
QueryBuilder.prototype.getUniqueFilterFields = function () { | ||
var filterFields = new Set(); | ||
var scanGroup = function (group) { | ||
group.groups.forEach(function (subGroup) { | ||
subGroup.conditions.forEach(function (condition) { | ||
filterFields.add(condition.field); | ||
}); | ||
}); | ||
}; | ||
this.query.forEach(function (queryGroup) { | ||
scanGroup(queryGroup); | ||
}); | ||
return Array.from(filterFields); | ||
}; | ||
/** | ||
* Retrieves the constructed query. | ||
@@ -125,0 +143,0 @@ * @returns The constructed query. |
{ | ||
"name": "@vepler/property-query-builder", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "The Propbar Property Query SDK is a TypeScript library that enables the easy construction of complex queries for searching and filtering data. It offers a fluent and intuitive API for building queries with multiple groups and conditions.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,2 +7,3 @@ # Propbar Property Query SDK | ||
- [] Add documentation for loadQuery method | ||
- [] Add documentation for getUniqueFilterFields method | ||
@@ -9,0 +10,0 @@ ## Installation |
@@ -19,2 +19,3 @@ // src/index.d.ts | ||
public getQuery(): Query; | ||
public getUniqueFilterFields(): string[]; | ||
@@ -21,0 +22,0 @@ private generateGroupId(): string; |
@@ -134,3 +134,25 @@ import { Condition, Operator, Query, QueryGroup } from './query-builder-types'; | ||
} | ||
/** | ||
* Retrieves an array of unique filter fields used in the current query. | ||
* @returns An array of unique filter fields. | ||
*/ | ||
public getUniqueFilterFields(): string[] { | ||
const filterFields: Set<string> = new Set(); | ||
const scanGroup = (group: QueryGroup) => { | ||
group.groups.forEach((subGroup) => { | ||
subGroup.conditions.forEach((condition) => { | ||
filterFields.add(condition.field); | ||
}); | ||
}); | ||
}; | ||
this.query.forEach((queryGroup) => { | ||
scanGroup(queryGroup); | ||
}); | ||
return Array.from(filterFields); | ||
} | ||
/** | ||
@@ -137,0 +159,0 @@ * Retrieves the constructed query. |
Sorry, the diff of this file is not supported yet
40023
21
775
271