@bijectionhq/app-documents to observe one MongoDB 6.0 or later
collection under the label you pass as data.
Mount and start
documents({ data, provider }) returns the app to place at a path of your
tree. Bind the collection with mongodbCollection(endpoint, credential, label).
app.ts
docs.operator is granted from code: ctx.grant(docs.operator, { to, under }) in one of your
mutations (Grants).
Set the credential to JSON with four strings.
Database and collection names may contain ASCII letters, digits, hyphens
and underscores. Grant
listCollections on the database and find on the
selected collection. The server certificate must be valid for the configured
host under the deployment’s platform trust. The connector uses one direct,
TLS-enabled endpoint with socket egress and makes no topology discovery.
Use one label for the receiver and the mount. The mount’s operator role
clears it and is the only role docs.source.*, docs.documents.list and
docs.documents.get allow. The host charges retained work against that
label’s reservation.
Paging and recovery
Each exchange reads at most one document in ascending_id order. The app
requires ObjectId keys and retains typed document images. The list and
get queries render each payload as canonical Extended JSON.
It admits at most 36 KiB of document JSON and 48 KiB of encoded answer
record. BSON nesting and field counts are bounded. JavaScript with scope
is outside this mode.
The driver reads the collection UUID before and after the page. A collection
replacement stops advancement and keeps the prior cursor. Use
source.health to get the revision and gap instant for source.reset.
Resetting starts a new traversal and keeps earlier observations under their
original collection identity. Each row and its position commit together.
Traversals repeat after reaching the end. Pages can observe concurrent
writes. The app makes no snapshot or deletion-by-absence inference.
Follow a change stream
Use the same mount with{ selection: { mode: "mongo-changes" } }. Point
the fixed endpoint at a MongoDB 6.0 or later replica-set member that can
serve change streams. Grant changeStream and find on the collection
and keep the existing listCollections grant. Enable
changeStreamPreAndPostImages on the collection and retain its images and
oplog long enough for the poller to resume.
The first read records the stream head. This mode captures subsequent
independently committed events, without a table scan. It applies inserts,
replacements and updates using exact post-images, and deletes by ObjectId.
Each accepted event commits with its opaque BSON resume token. An empty
batch can advance to the provider’s post-batch token. The connector
closes the provider cursor after each read and requests resumeAfter
with the committed token on the next read.
One event can occupy up to 36 KiB of document JSON and 48 KiB of encoded
answer. Transactions carrying a session and transaction number, missing
required post-images and oversized events block advancement.
An invalidated stream, a lost resume token or a changed collection UUID
requires explicit reset. Resetting starts at the current head and retains
previously published rows. Deletion by absence is outside this mode.
MongoDB X.509 client configuration