gpt4 book ai didi

DocumentDB listchangestreams()

转载 作者:bug小助手 更新时间:2023-10-27 20:33:29 30 4
gpt4 key购买 nike



Following the AWS documentation we are trying to list all change streams using the command

按照AWS文档,我们尝试使用以下命令列出所有更改流


cursor = new DBCommandCursor(db,
db.runCommand(
{aggregate: 1,
pipeline: [{$listChangeStreams: 1}], cursor:{}}));

We are running this in the MongoSH provided in the MongoDB Compass application. But we are getting an error that says: "ReferenceError: DBCommandCursor is not defined". I am completely lost on how to solve this.

我们在MongoDB Compass应用程序中提供的MongoSH中运行它。但我们收到一条错误消息:“ReferenceError:DBCommandCursor未定义”。我完全不知道如何解决这个问题。


更多回答
优秀答案推荐

Try running the command without wrapping it in a DBCommandCursor:

尝试运行该命令,但不将其包装在DBCommandCursor中:


db.runCommand(
{aggregate: 1,
pipeline: [{$listChangeStreams: 1}], cursor:{}});

Your change streams will be listed in the cursor.firstBatch array of the results.

您的变更流将列在结果的cursor.first stBatch数组中。


If you need to see more results (i.e., if the default batch size is too small), you can use the batchSize parameter:

如果您需要查看更多结果(即,如果默认批处理大小太小),可以使用BatchSize参数:


db.runCommand(
{aggregate: 1,
pipeline: [{$listChangeStreams: 1}], cursor:{"batchSize": 1000}});

Be sure to connect to the cluster endpoint (or directly to the primary instance endpoint), otherwise you will get this error:

请确保连接到集群终结点(或直接连接到主实例终结点),否则将收到以下错误:


MongoServerError: Aggregation stage not supported: '$listChangeStreams'

更多回答

That was it. I can't believe I didn't try that.

就这样了。我真不敢相信我居然没试过。

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com