You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -25,7 +25,7 @@ You can see an example of the default validator in action in the [demo](https://
25
25
### `findPath`
26
26
27
27
```ts
28
-
function findPath(path:number[], query:RuleGroupType):RuleType|RuleGroupType;
28
+
function findPath(path:number[], query:RuleGroupTypeAny):RuleType|RuleGroupTypeAny;
29
29
```
30
30
31
31
`findPath` is a utility function for finding the rule or group within the query hierarchy that has a given `path`. Useful in custom [`onAddRule`](./querybuilder#onaddrule) and [`onAddGroup`](./querybuilder#onaddgroup) functions.
@@ -42,6 +42,22 @@ function convertQuery(query: RuleGroupTypeIC): RuleGroupType;
42
42
43
43
`convertToIC` and `convertFromIC` do the same thing as `convertQuery`, but only in one direction.
44
44
45
+
### `transformQuery`
46
+
47
+
```ts
48
+
function transformQuery(query:RuleGroupTypeAny, options:QueryTransformerOptions):any;
49
+
```
50
+
51
+
This function recursively steps through nested `rules` arrays in a `RuleGroupType` or `RuleGroupTypeIC`, passing each `RuleType` object to a provided `ruleProcessor` function. Several other options are also available:
52
+
53
+
-`ruleGroupProcessor`: Custom processing for each rule group. (The `rules` property will be overwritten.)
54
+
-`propertyMap`: Keys in the rule or group objects that match keys in this object will be renamed to the corresponding value.
55
+
-`combinatorMap`: Best explained with an example: `{and: "&&", or: "||"}` would translate "and"/"or" combinators to "&&"/"||", respectively.
56
+
-`operatorMap`: Convert operators that match the keys in this object to the corresponding values, e.g. `{"=": "=="}`.
57
+
-`deleteRemappedProperties`: Defaults to `true`; pass `false` to leave the remapped properties _and_ the original properties in the resulting object.
58
+
59
+
See the [test suite](https://github.com/react-querybuilder/react-querybuilder/blob/main/packages/react-querybuilder/src/utils/transformQuery.test.ts) for example usage.
60
+
45
61
## Query tools
46
62
47
63
Several methods are available to assist with manipulation of query objects outside the context of the `<QueryBuilder />` component:
0 commit comments