spring - Spring MongoDB AggregationOperation 获取文档ID
问题描述
我正在尝试在 Mongodb 聚合操作期间获取对文档 ID 的引用
代码如下
Aggregation aggregation = newAggregation(
(AggregationOperationContext aoc) -> {
System.out.println(aoc.getReference("$_id").getReferenceValue());
return new Document("$set", new Document("field", "1"));
}
);
运行此代码仅打印出数字 1
我试过而不是$_id
只是id
and _id
,同样的结果
解决方案
推荐阅读
- ibm-appid - 如何使用 IBMid 身份提供者配置 Appid 服务
- three.js - 限制 aframe 项目的帧速率
- android - EventBus:两个订阅者:没有订阅者注册事件类 org.greenrobot.eventbus.NoSubscriberEvent
- regex - 检查字符串中的值的函数
- sql - SQL - exclude refunded transactions on new line
- powershell - Oracle 管理单元或模块的可用性
- c# - 我可以在 CASE 中使用 ENUM 而不是带有 Enum 的 switch 语句吗?
- python - 用于决定操作的数据框中的时间戳分析
- xslt - XSL 将特定值排序到最后
- list - Scheme/Racket:将一个列表分成两个元素列表的函数,这些元素匹配某个谓词和不匹配它的元素