Skip to content

Conversation

jb55
Copy link
Contributor

@jb55 jb55 commented Apr 9, 2025

This PR adds "custom filter" functionality to ndb_filter. This allows you to include a custom callback function in a filter to add any custom filtering logic you want

Motivation

Sometimes there is lots of data to scan through that has tags with a specific structure. For example, you might want to pull only root kind 1 threads. There is no concept of "negative queries" in nostr, where you look for the absence of some fields. Custom queries allows you to perform additional logic on the query to exclude things like kind1 thread replies.

See only_threads_filter in test.c for an example

This adds some helpers for adding custom filtering logic
to nostr filters. These are just a callback and a closure.
There can only be one custom callback filter per filter.

Fixes: #33
Signed-off-by: William Casarin <[email protected]>
@jb55 jb55 force-pushed the custom-filters branch from 9b75c66 to 9adb0b8 Compare April 9, 2025 03:01
@jb55 jb55 linked an issue Apr 9, 2025 that may be closed by this pull request
Signed-off-by: William Casarin <[email protected]>
@jb55 jb55 merged commit 44d1797 into master Apr 14, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

Filter queries

1 participant