亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

node.js - How to delete array elements in mongoose
PHPz
PHPz 2017-05-24 11:35:44
0
1
1396

Now there are two schemas, one is students and the other is students’ employment information

var Student = new mongoose.Schema({
    jobs:[{
        type:ObjectId,
        ref: 'job'
    }]
});

var job = new mongoose.Schema({
    student:{
        type: ObjectId,
        ref: 'student'
    }
})

刪除一條job文檔的時(shí)候如何把學(xué)生文檔的jobs數(shù)組中該job的ObjectId也刪了,
我用了如下的寫法:
Job.remove({_id:_id}, function(err,job){
    var jobId = job._id;
    Student.update({_id:StudentId},{
    $pull:{jobs:{ObjectId: jobId}}
    }, function(){})
})

This will report an error, what is the correct way to write it

PHPz
PHPz

學(xué)習(xí)是最好的投資!

reply all(1)
阿神

It feels superfluous. These are just references. The data in the real database will be filled in during populate. How can the deleted data be referenced?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template