Skip to content
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

Help others discover this library #12

Closed
Mihailoff opened this issue Jul 11, 2023 · 4 comments
Closed

Help others discover this library #12

Mihailoff opened this issue Jul 11, 2023 · 4 comments

Comments

@Mihailoff
Copy link
Contributor

After evaluating a number of options I luckily found your repo.

With the .build() method execution time went down significantly thus I'm quite happy with your library so far.

For my use case, a combination of https://github.com/mithunsatheesh/node-rules and https://github.com/TotalTechGeek/json-logic-engine makes up quite a robust rules engine.

@TotalTechGeek
Copy link
Member

TotalTechGeek commented Jul 13, 2023

Thank you for your contribution! I appreciate you reaching out!

I'm currently on a trip, but when I get a chance I'll try to merge and release the tag changes.

If I may ask:

What features in Node-Rules are being used most extensively in your project?

I'm curious to see if I could provide a supplementary module to complement this package to better serve some lightweight use-cases.

@Mihailoff
Copy link
Contributor Author

In my case, I process an array of documents and emit them when matched

const list = [doc1, doc2, ...]
list.forEach(doc => {
  if (logicEngine.run(doc)) emit(doc)
})

list.filter() doesn't work because there is a bit of logic in emit, this is one case why node-rules is handy.

Conceptually it is made for processing lists and it breaks the flow into the condition stage and action stage. JsonLogic is perfect for the condition stage but has nothing to offer for processing a list of documents.

Maybe this is just fine to limit the scope of the library to a document level. An example would be helpful, at the beginning, it was not clear how to use JsonLint-like libraries for lists.

@TotalTechGeek
Copy link
Member

Conceptually it is made for processing lists and it breaks the flow into the condition stage and action stage. JsonLogic is perfect for the condition stage but has nothing to offer for processing a list of documents.

Right, definitely not on it's own! At least... not without unreasonable amounts of nesting higher order instructions & adding new methods.

However, as JSON-Logic can be used to wrap any function, I have paired it successfully in the past with libraries like RxJS to create declarative pipelines to handle streams of documents,

{
  "map": { "var": "body" } 
},
{
  "filter": { ">": [{ "var": "age" }, 21] }
},
{
  "bufferCount": 25
},
{
 "tap": { "log": "Publishing batch of 25..." }
}

I might want to provide a recipes page to show json-logic paired with libraries like Node-Rules and RxJS.

An example would be helpful, at the beginning, it was not clear how to use JsonLint-like libraries for lists.

A fair point! I think there's a lot of improvement that could be done on the docs. I may prioritize this soon.

@Mihailoff
Copy link
Contributor Author

Looks interesting. Theoretically, we could implement similar to Node-Rules flow control as custom methods. We need some examples of how to work with methods, especially parameters. logic.addMethod('+1', (item) => item + 1) is great for basic operations but not sufficient for more complex use cases.

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