Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Mongoose子文档不更新时间戳_Node.js_Mongodb_Mongoose - Fatal编程技术网

Node.js Mongoose子文档不更新时间戳

Node.js Mongoose子文档不更新时间戳,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,我有一个简单的模式,如下所示 var childSchema = new Schema( { childName: String, }, { timestamps: true } ); var parentSchema = new Schema({ child: [childSchema] }, { timestamps: true } ) 当我在代码下面运行时,父级的updateeat

我有一个简单的模式,如下所示

var childSchema = new Schema(
    {
        childName: String,
    },
    {
        timestamps: true
    }
);


var parentSchema = new Schema({
    child: [childSchema]
},
    {
        timestamps: true
    }
)
当我在代码下面运行时,父级的
updateeat
会更改,但子级的
updateeat
不会更改。我做错了什么

var query = {};
var setValue = { "child.$[].childName": "Dummy Day" };
var options = { upsert: true, safe: true, multi: true}
var callback = function (err, result) {
    if (err) {
        return res.send(err);
    }
    return res.send(result)
}
Parent.update(query, { $set: setValue }, options, callback)

您使用的是哪种版本的猫鼬?查看并@chridam我正在使用5.3.1,我已经参考了你提到的那些链接。谢谢但是医生没有按照我的要求更新