相关疑难解决方法(0)

mongodb中的Redact似乎对我来说很模糊

我现在正在与redact斗争,我不确定理解它.

我只是阅读了文档并试图在集合等级上使用redact(它来自mongodb在线培训)

集合"成绩"中的文档如下所示:

{
    "_id" : ObjectId("50b59cd75bed76f46522c34e"),
    "student_id" : 0,
    "class_id" : 2,
    "scores" : [ 
        {
            "type" : "exam",
            "score" : 57.92947112575566
        }, 
        {
            "type" : "quiz",
            "score" : 21.24542588206755
        }, 
        {
            "type" : "homework",
            "score" : 68.19567810587429
        }, 
        {
            "type" : "homework",
            "score" : 67.95019716560351
        }, 
        {
            "type" : "homework",
            "score" : 18.81037253352722
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我使用以下查询:

db.grades.aggregate([
    { $match: { student_id: 0 } },
    { 
        $redact: {
            $cond: {
                if: { $eq: [ "$type" , "exam" ] …
Run Code Online (Sandbox Code Playgroud)

mongodb aggregation-framework

6
推荐指数
1
解决办法
1924
查看次数

标签 统计

aggregation-framework ×1

mongodb ×1