I know we can use Mongo shell to enable(or disable) change streams for Amazon Document DB. Is it possible to enable the change streams from AWS Console or MongoDB Driver?
Enable change streams for Amazon DocumentDB
3.6k views Asked by chvc At
2
There are 2 answers
0
On
You can enable changestreams on your Amazon DocumentDB cluster using the modifyChangeStream API. To enable/disable changestreams using the mongo shell -
//Enable change streams for the collection "foo" in database "bar"
db.adminCommand({modifyChangeStreams: 1,
database: "bar",
collection: "foo",
enable: true});
//Enable change streams for all collections in database "bar"
db.adminCommand({modifyChangeStreams: 1,
database: "bar",
collection: "",
enable: true});
//Enable change streams for all collections in all databases in a cluster
db.adminCommand({modifyChangeStreams: 1,
database: "",
collection: "",
enable: true});
To enable change streams from your application, you can use @krg265's suggestion.
AWS Console: No. I don't think this is controlled by DocumentDB cluster params.
MongoDB Drivers: Yes
DocumentDB Change Streams uses runCommand method to enable and disable changestreams. In the documentation, the command used is
adminCommand
which is just callingrunCommand
onadmin
database. Since almost all drivers support running commands over database, you should be able to enable/disable change streams using any driver.Following code uses pymongo to enable changestreams: