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

Question: manipulate arrays of objects #89

Open
dma82 opened this issue Jul 29, 2020 · 0 comments
Open

Question: manipulate arrays of objects #89

dma82 opened this issue Jul 29, 2020 · 0 comments

Comments

@dma82
Copy link

dma82 commented Jul 29, 2020

Hi,

Would it be possible to load examples with complex facts, e.g. object with nested array of objects? How would you manipulate them?

Example:

var fact = {
  "parentObject": {
        "id": "abc123",
        "items": [{
             {
                 "id": 1,
                 "parentId": "abc123",
                 "status": null
             },
             {
                 "id": 2,
                 "parentId": "def234",
                 "status": null
             },
            {
                 "id": 3,
                 "parentId": "abc123",
                 "status": null
            }
        }]
   }
}

Let's say now that I want to create a rule to change the status of all objects in "items" array where parentId = parentObject.id; how can I achieve this?

In Drools (Java) I was able to bind to the object with those conditions to a variable and then to manipulate it in the "then" part, after I loaded all objects into the working memory.

Is there any way to achieve the same result with this library? Is there a better way other than loading each individual object into the working memory?

Maybe I missed it, but I couldn't find any example.

Thank you.

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