You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
query GoodbyeQuery {
when
{
m : Message m.text =~ /.*goodbye$/;
}
The results is an array of matched facts.
To use from a session:
//Accumlate the matching facts by pushing them onto an array
var matchedFacts = session.getQueryResults("GoodbyeQuery");
console.log(matchedFacts[0].m);
Adding parameters would be very helpful. Might use some for of the existing
options syntax to define params:
query GoodbyeQuery {
parameters : { regex : null };
when
{
m : Message m.text =~ parameters.regex; // or just regex
}
Note that multiple matches and parameters can be supplied:
query FindFriends {
parameters : { $zipcode : null, $firstName:null, $lastName:null };
when
{
p: Person:
a: Address a.zipcode == $zipcode from p.address;
first: String first ==$firstName from p.firstName;
last: String last == $lastName from p.lastName;
}
var matchedFacts = session.getQueryResults("FindFriends", { $zipcode: '88847' , $firstName:'bob' , $lastName:'yukon'} );
console.log(matchedFacts);
Don't have a pull request on this, but, have done some experimental coding locally.
To be like DROOLs you would drop the "when" all together of course, and handle the parameters
differently. We just
made it easy on ourselves my lightly tweaking the existing parsing code..
The text was updated successfully, but these errors were encountered:
In the nools DSL something like this:
query GoodbyeQuery {
when
{
m : Message m.text =~ /.*goodbye$/;
}
The results is an array of matched facts.
To use from a session:
//Accumlate the matching facts by pushing them onto an array
var matchedFacts = session.getQueryResults("GoodbyeQuery");
console.log(matchedFacts[0].m);
Adding parameters would be very helpful. Might use some for of the existing
options syntax to define params:
query GoodbyeQuery {
parameters : { regex : null };
when
{
m : Message m.text =~ parameters.regex; // or just regex
}
//To run:
var matchedFacts = session.getQueryResults("GoodbyeQuery", { regex : ' /.*goodbye$/'} );
console.log(matchedFacts);
Note that multiple matches and parameters can be supplied:
query FindFriends {
parameters : { $zipcode : null, $firstName:null, $lastName:null };
when
{
p: Person:
a: Address a.zipcode == $zipcode from p.address;
first: String first ==$firstName from p.firstName;
last: String last == $lastName from p.lastName;
}
var matchedFacts = session.getQueryResults("FindFriends", { $zipcode: '88847' , $firstName:'bob' , $lastName:'yukon'} );
console.log(matchedFacts);
Don't have a pull request on this, but, have done some experimental coding locally.
To be like DROOLs you would drop the "when" all together of course, and handle the parameters
differently. We just
made it easy on ourselves my lightly tweaking the existing parsing code..
The text was updated successfully, but these errors were encountered: