Ability to remove rules by name
See original GitHub issueI’m building a service using this engine. The users are able to add and remove rules whenever they want. I’m having troubles on the removal process.
Every time a user adds a rule, I create a new rule using let rule = new engine.Rule(options)
. With that rule I do two things:
1.- Save the JSON to the filesystem, so every time I need to reload the service I could recreate the rules. 2.- Add the rule to then engine.
This works great. The problem that I have is when I try to remove a rule. For that process the user gives me the name of the rule an I do the following:
1.- Find in the filesystem the .json
file that correspond to the name the user gives me.
2.- Create a json object from that file:
let ruleFromJson = JSON.parse(fs.readFileSync(file, { encoding: 'UTF-8' }))
3.- Create a Rule from that object:
let rule = new engine.Rule(ruleFromJson);
4.- Remove the rule:
engine.removeRule(rule);
After doing that if I run the engine passing a fact that match the deleted rule, the engine still throw onSuccess
with that rule.
What I’m doing wrong?
Versions:
- Node: 10.16.0
- JSON Rules Engine: 4.0.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (9 by maintainers)
Top GitHub Comments
Now available in 6.1.X
@CacheControl , you’re right. The engine method
removeRule()
return false. As you do in the quick fix I manually remove the rule. We’ll wait until this feature to come out. Thanks!