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

Support Ditto searches comparing values of the twin data #2098

Open
thjaeckle opened this issue Jan 17, 2025 · 0 comments
Open

Support Ditto searches comparing values of the twin data #2098

thjaeckle opened this issue Jan 17, 2025 · 0 comments

Comments

@thjaeckle
Copy link
Member

There are scenarios where one would not like to define a concrete value to search for, e.g.:

lt(features/heartbeat/properties/lastReceiveTime,time:now-2h)

But instead compare 2 (or more) values in the twin, e.g. (in this example, relying on that nextExpectedReceiveTime is updated with each lastReceiveTime dynamically to the next expected "heartbeat" message from a device):

lt(features/heartbeat/properties/lastReceiveTime,features/heartbeat/properties/nextExpectedReceiveTime)

I found that the MongoDB $expr might be able to do such queries:
Compare Two Fields from a Single Document

We would need to:

  • make sure that $expr really works for such a use case
  • define how the RQL queries could look like, targeting a dynamic value from the twin
  • enhance Ditto's search service to be able to map to BSON
  • enhance Ditto's ThingPredicateVisitor to also support this (e.g. in order to be used within condition)
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

1 participant