For databases that are not replica sets and sharded clusters, how to implement a similar function to db.collection.watch, that is, to monitor the changes of the database in real time?
db.collection.watch is For replica sets and sharded clusters only .
@masx200_masx200Change streams require a replica set or sharded cluster deployment because the mechanism for monitoring data changes is provided by the replication oplog which does not exist in a standalone deployment.
However, you can create a single member replica set deployment for testing or development purposes. To do so, follow the tutorial to Convert a Standalone to a Replica Set but do not add any additional members after initialising the replica set.
The main downsides of a single member deployment are that you don’t get any of the usual replica set benefits such as data redundancy and fault tolerance. A replica set member also has some expected write overhead as compared to a standalone server because it has to maintain the oplog.