Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-place data update #131

Open
luizender opened this issue Jun 28, 2023 · 0 comments
Open

In-place data update #131

luizender opened this issue Jun 28, 2023 · 0 comments

Comments

@luizender
Copy link

Hello gays,
Is there a way to do an in-place data update?

For exemple, I have de following rule:

{
  "if": [
    { "some": [{ "var": "groups" }, { "==": [{ "var": "name" }, "group_1"] }] },
    { "merge": [{ "var": "" }, [{ "id": 2, "name": "group_2" }]] }
  ]
}

using the following data:

{
  "id": 1,
  "name": "test",
  "groups": [{ "id": 1, "name": "group_1" }],
  "tags": [{ "id": 1, "name": "tag_1" }],
  "category": {
    "id": 1,
    "name": "category_1",
    "fields": [
      {
        "id": 1,
        "name": "field_1",
        "kind": "str",
        "value": "hello word"
      }
    ]
  }
}

then I want, as result, the following:

{
  "id": 1,
  "name": "test",
  "groups": [
    { "id": 1, "name": "group_1" },
    { "id": 2, "name": "group_2" }
  ],
  "tags": [{ "id": 1, "name": "tag_1" }],
  "category": {
    "id": 1,
    "name": "category_1",
    "fields": [
      {
        "id": 1,
        "name": "field_1",
        "kind": "str",
        "value": "hello word"
      }
    ]
  }
}

As my rule, the field groups in the data was updated to:

[
  { "id": 1, "name": "group_1" },
  { "id": 2, "name": "group_2" }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant