Java 如何在mongo模板中为聚合中的$编写mongo cli查询
这就是我的数据的样子Java 如何在mongo模板中为聚合中的$编写mongo cli查询,java,mongodb,spring-boot,mongodb-query,aggregation-framework,Java,Mongodb,Spring Boot,Mongodb Query,Aggregation Framework,这就是我的数据的样子 { "_id" : "2011250546437843117", "name" : "Book", "textbook" : [ "Maths", "Science" ], "langu
{
"_id" : "2011250546437843117",
"name" : "Book",
"textbook" : [
"Maths",
"Science"
],
"language" : [
"English"
],
"isRead" : true,
"isAvailable" : true
}
我必须根据教科书筛选文档,并且根据该isRead字段应为真或假。
我的mongo查询是
db.user.aggregate([
{
$match: {
"isAvailable": true
}
},
{
$project: {
"textbook": 1,
"name": 1,
"isread": {
$in: [
"Maths",
"$textbook"
]
}
}
}
]);
我试着用mongo模板写这个
Aggregation aggregation = newAggregation(match(Criteria.where("isAvailable").is(true)),
project("textbook","name"));
我不知道如何在项目阶段编写$in操作符
提前谢谢。类似问题:类似问题: