我有一個與下面的代碼問題我刪除用戶和更新用戶列表到客戶端,所以當我調用API刪除用戶需要一段時間刪除和我更新的userList呈現數據包括已刪除的用戶。如何正確執行刪除?如何從mongodb中刪除文件並更新客戶端?
controller.js
export function destroy(req, res) {
console.log(req.params.id);
UserAccess.findOne({
attuid: req.params.id
}, function(err, user) {
if (user) {
user.remove();
}
});
}
這將返回用戶列表
export function index(req, res) {
UserAccess.findAsync()
.then(responseWithResult(res))
.catch(handleError(res));
}
index.js
router.get('/', controller.index);
router.delete('/:id', controller.destroy);
我們如何在myBove代碼中調用'index'的getUserList函數? – hussain
if(!err && removed){index}(req,res); } –
謝謝你解決了我的問題! – hussain