Skip to content

Declarative way for compute facts #292

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

Open
madbonez opened this issue Feb 27, 2022 · 0 comments
Open

Declarative way for compute facts #292

madbonez opened this issue Feb 27, 2022 · 0 comments
Milestone

Comments

@madbonez
Copy link

madbonez commented Feb 27, 2022

Hi! I consider this repo as a very helpful design approach! I'm looking forward and have thoughts about admin interface for editing and storing rules. But i think we have a lack of ability for storing complex computed facts. For example, i have a a big legacy system underneath my app, and some facts from there have a big value because they computes from multiple fields of big json document. I need to reuse that facts everywhere in my app. What can i do right now? I can use only functions for this objectives. Like this:

engine.addFact('account', (params, almanac) => {
    return almanac.bigDoc.path1.value + almanac.bigDoc.path2.value;
})

Ok, it's very flex and this approach cover all my needs, except storing.

My suggest:

We can use jsonLogic library (or similar operators inside this repo) for declaring facts like this:

new Fact('derivedFact', [ 'bigDoc' ], { '+' : [
        { 'var' : 'bigDoc.path1.value' },
        { 'var' : 'bigDoc.path2.value' },
    ]}
)

While i was browsing docs, i saw that you considered this as a design bad smell. Why? Can you explain? Or i can suggest PR? 🙂

@chris-pardy chris-pardy added this to the version 7 milestone Aug 25, 2023
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

2 participants