-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from GetFeedback/improve-insert-field-step
Improve insert field step
- Loading branch information
Showing
3 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,8 +96,8 @@ Another for the drink: | |
{ | ||
"customer": "Paolo", | ||
"order": { | ||
"type": "food", | ||
"product": "pizza" | ||
"type": "drink", | ||
"product": "cocacola" | ||
} | ||
} | ||
``` | ||
|
@@ -150,12 +150,35 @@ Wraps the current content in a single field. | |
## Insert Static Value | ||
Insert a static value in a chosen field of the value object; if the field exists, the action will be skipped, and eventually is possible to configure the step with `overrideIfExists: true` to permit the override. | ||
|
||
Let's take as example this record: | ||
|
||
```yaml | ||
{ | ||
"name": "Paolo", | ||
"email": "[email protected]" | ||
} | ||
``` | ||
|
||
We want to add a new field `type`, so our record will look like this: | ||
|
||
```yaml | ||
{ | ||
"name": "Paolo", | ||
"email": "[email protected]", | ||
"type": "customer" | ||
} | ||
``` | ||
|
||
So, our step configuration will look like this: | ||
|
||
```yaml | ||
- name: addNewField | ||
type: dev.vox.platform.kahpp.configuration.transform.InsertStaticFieldTransform | ||
config: | ||
field: newField | ||
value: foo | ||
field: type | ||
value: customer | ||
``` | ||
|
||
### Insert JSON Value | ||
|
@@ -171,6 +194,19 @@ Eventually, we can also add a static JSON value. | |
``` | ||
|
||
### Override an existing field | ||
|
||
It's also possible to override an existent field. | ||
|
||
```yaml | ||
- name: addNewJsonField | ||
type: dev.vox.platform.kahpp.configuration.transform.InsertStaticFieldTransform | ||
config: | ||
field: email | ||
value: '*****' | ||
overrideIfExists: true | ||
``` | ||
|
||
## Conditional | ||
|
||
All transformer steps can be triggered conditionally using the parameter `condition`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters