Feature Request: Native "Left Anti-Join" / efficient excluding of relationships (Block functionality) #15408
sayem314
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I need to efficiently exclude documents based on the existence of a related document in another collection (a "Left Anti-Join").
Example Use Case: "Blocks" or "Muted Users" in a social app.
userscollectionblockscollection:{ blocker: relationship(users), blocked: relationship(users) }Goal: Find all
usersEXCEPT those present in theblockscollection for the current user.Current Limitations
not_in):Fetch all blocked IDs ->
where: { id: { not_in: [1000+ ids] } }.Issue: Hits URI/Memory limits with large block lists.
Add
blockedByarray to User.Issue: High complexity to keep synced (syncing on create/delete/update).
Use
$lookupin a custom endpoint.Issue: Bypasses Payload completely (loses
afterReadhooks, virtuals, populates, and automatic typing).Feature Request
A native Local API way to filter based on the absence of a relationship.
Is there any existing pattern to achieve this scalable "Anti-Join" without dropping down to raw DB adapters or denormalizing?
Beta Was this translation helpful? Give feedback.
All reactions