Javascript Don';t在MongoDB中将null替换为零

Javascript Don';t在MongoDB中将null替换为零,javascript,mongodb,aggregation-framework,Javascript,Mongodb,Aggregation Framework,我编写了一个mongo shell脚本,在新集合中插入聚合的结果;我的问题是源集合中的空值被零替换;聚合部分是: db.getCollection("unhcr_pop_concern_flat").aggregate( [ { "$group" : { "_id" : { "country"

我编写了一个mongo shell脚本,在新集合中插入聚合的结果;我的问题是源集合中的空值被零替换;聚合部分是:

db.getCollection("unhcr_pop_concern_flat").aggregate(
    [ 
        { 
            "$group" : {
                "_id" : {
                    "country" : "$country", 
                    "time" : "$time",
                    "origin": "$origin"
                },
      "value_fields": {
        "$addToSet": {
          k: "$type",
          v: {$ifNull: ["$value", null]}
        }
      }
            }
        },
        { $addFields: { value_fields: { $arrayToObject: "$value_fields" } } }
    ], 
    { 
        "allowDiskUse" : true
    }

问题在哪里?我还使用了$ifnull运算符。

查询工作正常;源集合中的数据被其他人更改时出现问题

你能分享一些数据吗?