Copy the code into getIdsBySearch >:(

This commit is contained in:
Alex Gleason 2025-02-05 22:56:02 -06:00
parent 6cf5d42a5b
commit c5680150e6
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -79,14 +79,27 @@ export async function getIdsBySearch(
}
}
for (const [key, values] of Object.entries(ext)) {
if (key === 'domain') continue;
for (let [key, values] of Object.entries(ext)) {
if (key === 'domain' || key === '-domain') continue;
query = query.where((eb) =>
eb.or(
values.map((value) => eb('nostr_events.search_ext', '@>', { [key]: value })),
)
);
let negated = false;
if (key.startsWith('-')) {
key = key.slice(1);
negated = true;
}
query = query.where((eb) => {
if (negated) {
return eb.and(
values.map((value) => eb.not(eb('nostr_events.search_ext', '@>', { [key]: value }))),
);
} else {
return eb.or(
values.map((value) => eb('nostr_events.search_ext', '@>', { [key]: value })),
);
}
});
}
if (domains.size) {