Automattic / Automattic/monk

Collection Watch - Change Streams

Open
#271 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.8k
Forks
180
PR merge metrics
No merged PRs in 30d

Description

Hi all,

How can I watch Change Streams with monk?
```js
const MongoClient = require("mongodb").MongoClient;
const assert = require("assert");
/*
Modify Change Stream Output using Aggregation Pipelines
You can control change stream output by providing an array of one or more of the following pipeline stages when configuring the change stream:
$match, $project, $addFields, $replaceRoot, $redact
See Change Events for more information on the change stream response document format.
*/
const pipeline = [
{
$project: { documentKey: false }
}
];
MongoClient.connect("mongodb://localhost:27017,localhost:27018,localhost:27019?replicaSet=mongo-repl")
.then(client => {
console.log("Connected correctly to server");
// specify db and collections
const db = client.db("superheroesdb");
const collection = db.collection("superheroes");

const changeStream = collection.watch(pipeline);
// start listen to changes
changeStream.on("change", function(change) {
console.log(change);
});

})
.catch(err => {
console.error(err);
});
```

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no Monk file, test, or entry point. Start by checking how Monk exposes collection operations and whether MongoDB collection.watch is supported; done should be a confirmed, documented way to use change streams or a clearly scoped implementation plan.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.