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();
No matter where I add limit(5) I get back the same results. I've tried asking a few people but nobody seems to know how to fix it, But, trying on here, hopefully someone knows mongodb enough in dart to suggest a solution