From 2d02766461031fba5e3e7a08212723b185ef1317 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 13 Jan 2025 18:08:47 -0800 Subject: [PATCH] nostrdb: filter: add ndb_filter_find_search helper This can be used to quicky pull the search string from a filter Signed-off-by: William Casarin --- nostrdb/src/nostrdb.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c index 8c9519b9..451b284a 100644 --- a/nostrdb/src/nostrdb.c +++ b/nostrdb/src/nostrdb.c @@ -2906,6 +2906,16 @@ ndb_filter_find_elements(struct ndb_filter *filter, enum ndb_filter_fieldtype ty return NULL; } +static const char *ndb_filter_find_search(struct ndb_filter *filter) +{ + struct ndb_filter_elements *els; + + if (!(els = ndb_filter_find_elements(filter, NDB_FILTER_SEARCH))) + return NULL; + + return ndb_filter_get_string_element(filter, els, 0); +} + int ndb_filter_is_subset_of(const struct ndb_filter *a, const struct ndb_filter *b) { int i;