0
      final pipeline = AggregationPipelineBuilder()
      .addStage(Match(where
          .eq('_id', ObjectId.fromHexString(authDetails.subject))
          .map['\$query']))
      .addStage(Match(
          where.eq('messages.username', theirUsername).map['\$query']))
      .addStage(Project({
        '_id': 0, //You can use as:'customer' instead of this keyword.
        'messages': Filter(input: '\$messages', cond: {
          '\$eq': ['\$\$this.username', theirUsername]
        }).build(),
      }))
      .build();

无论我在哪里添加 limit(5) 我都会得到相同的结果。我试过问几个人,但似乎没有人知道如何解决它,但是,在这里尝试,希望有人在 dart 中足够了解 mongodb 以提出解决方案

4

0 回答 0