fix(backend): replace $contains with post-filter for webhook events array query
$contains generates CONTAINS() SQL in Cosmos (string match), not ARRAY_CONTAINS() needed for string[] fields. Use findMany + in-memory post-filter for correct behavior across both providers.
This commit is contained in:
parent
8731cf38fd
commit
4cb5d3e627
@ -96,10 +96,12 @@ export async function findSubscriptionsForEvent(
|
||||
productId: string,
|
||||
eventType: WebhookEventType
|
||||
): Promise<WebhookSubscriptionDoc[]> {
|
||||
// events is a string[] — $contains works for primitive arrays in memory provider
|
||||
return subsCollection().findMany({
|
||||
filter: { userId, productId, active: true, events: { $contains: eventType } },
|
||||
// $contains generates CONTAINS() SQL (string match) in Cosmos, not ARRAY_CONTAINS().
|
||||
// Use findMany + post-filter for correct behavior across both providers.
|
||||
const subs = await subsCollection().findMany({
|
||||
filter: { userId, productId, active: true },
|
||||
});
|
||||
return subs.filter(s => s.events.includes(eventType));
|
||||
}
|
||||
|
||||
// ── Increment Failure Count ───────────────────────────────────
|
||||
|
||||
Loading…
Reference in New Issue
Block a user