feat: Add MongoDB Document Backend With Embed Vs Reference - #8
Open
ThomasHartDev wants to merge 2 commits into
Open
feat: Add MongoDB Document Backend With Embed Vs Reference#8ThomasHartDev wants to merge 2 commits into
ThomasHartDev wants to merge 2 commits into
Conversation
Users embed outbound following for the feed $in path. Posts and inbound follow edges are referenced collections, with unique handle and edge indexes and a compound $or keyset cursor.
A real driver throws MongoServerError { code: 11000, keyPattern }. Duck-type
that shape so handle_taken and idempotent follow work for any adapter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The activity feed now has a document backend on the same ActivityStore port. Users embed their outbound following list so a home feed is one document read plus posts.find({ authorId: { $in } }). Posts live in their own collection with an authorId reference, because they grow without bound and would hit the 16 MiB BSON limit if nested. Inbound follows are edge documents for the same reason: celebrity inbound does not belong on the followee.
Follow dual-writes $addToSet on the user and a unique { followerId, followeeId } edge. Duplicate follow inserts (E11000, including a real-driver MongoServerError { code: 11000 }) are a no-op and still repair a missing embedded id. The unique pair index is independent of the synthetic edge _id. Keyset pagination uses $or so equal timestamps still total-order by _id. Same contract suite, plus tests that inspect the raw documents. Closes #7.