-1
您好我想从mongoDB中删除一个值,但不是删除特定的值,而是从架构中删除所有用户lol。从mongoDB数组中删除值
var mongoose = require('mongoose');
var User = require('../../models/UserModel');
module.exports.unfollow = function(req, res){
var thefollowee = req.body.followee;
var thefollower = req.body.follower;
User.find({_id: thefollower}).remove({following: thefollowee}).exec();
User.find({_id: thefollowee}).remove({followers: thefollower}).exec();
res.json({ message: 'Unfollowed'});
};
被关注被指向人的ID被人跟踪, 跟随指向谁跟随被关注用户的id。
我刚才看到你的答案弹出,但你也可能使用猫鼬的[findOneAndRemove](http://mongoosejs.com/docs/api .html#query_Query-findOneAndRemove)方法。 –