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
* Minor correction of typo that is finding its way into the Rust Docs.
* Create filters
* Modify Filters
* Other Filter operations
* Correction to nip05.py to remove unused classes from import
Closes#463
Signed-off-by: Yuki Kishimoto <[email protected]>
Though a web-socket subscription model relays can surface events that meet specific criteria on request.
4
+
The means by which these requests maybe submitted are JSON filters objects which can be constructed using a range of attributes,
5
+
including `ids`, `authors`, `kinds` and single letter `tags`, along with timestamps, `since`/`until` and record `limit` for the query.
6
+
7
+
The [Filters](https://docs.rs/nostr/latest/nostr/event/builder/struct.Filters.html) struct allows us to create and modify filter objects.
8
+
The available functions allow for both single (`author`) and multiple (`authors`) items to be added during creation/addition,
9
+
and the attribute specific remove functions (`remove_authors`) can be used to modify existing filter objects.
10
+
There are also some additional functions which cover logical tests namely `is_empty()` and `match_event()`.
11
+
12
+
## Create Filters
13
+
14
+
<custom-tabscategory="lang">
15
+
16
+
<divslot="title">Rust</div>
17
+
<section>
18
+
19
+
TODO
20
+
21
+
</section>
22
+
23
+
<divslot="title">Python</div>
24
+
<section>
25
+
26
+
The following code examples all utilise the `Filters()` along with associated methods to create filter objects and print these in JSON format using the `as_json()` method.
27
+
28
+
Filtering events based on a specific event ID using `id()`.
Restricting query results to specific timeframes (using `since()` and `until()`), as well as limiting search results to a maximum of 10 records using `limit()`.
Adding more conditions to existing objects can be done by simply calling the relevant method on the instance of the object.
115
+
In this example we create a initial filter with `pubkeys()`, `ids()`, `kinds()` and a single `author()` then modify the object further to include another kind (4) to the existing list of kinds (0, 1).
116
+
117
+
Similarly, the range of 'remove' methods (e.g. `remove_kinds()`) allow us to take an existing filter and remove unwanted conditions without needed to reconstruct the filter object from scratch.
0 commit comments