noolsjs / nools

Rete based rules engine written in javascript
http://noolsjs.com/
MIT License
951 stars 181 forks source link

Unable to modify fact matched using from #174

Open bbarvish opened 8 years ago

bbarvish commented 8 years ago

I have the following very basic rule which matches against all tables in a parent topic which have exactly 2 columns and a specific status:

rule Hello {
    when {
        $topic : Topic $topic.Id == "1";
        $t : Table $t.Status === "unknown" && $t.Columns.length === 2 from $topic.Tables;
    }
    then {
        console.log($t.Id + " is found with column count: " + $t.Columns.length + " and Status: " + $t.Status);
        modify($t, function(){ this.Status = "invalid"; } ) ;
    }
}

When I attempt to modify the matched fact's string property in working memory, i get the following error: "msg":"Error: the fact to modify does not exist\n at declare.instance.modifyFact

Why is the matched fact not "modify-albe"? What am I doing wrong here? The console statement is able to correctly output the matched fact's properties.

taoqf commented 8 years ago

Try this:

$t.Status = 'invalid';
modify($topic);