Skip to content

Question: manipulate arrays of objects #89

@dma82

Description

@dma82

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions