骨干,节点:当我调用 fetch 方法时,在服务器中获取成功但是当它使用发送回响应时
res.send(result)
它没有发送(可能是)任何模型,或者它正在发送旧模型,并且它只发送响应对象。模型是我想要的,我怎样才能得到?
app.get('/college/colleges/:_id', function (req, res) {
oid = new ObjectID(req.params._id.toString());
return CollegeModel.find({
_id: oid
}, function (err, result) {
if (!err) {
console.log("Fetched college model successfully");
res.send(result);
} else {
console.log("Error : " + err);
res.send(err);
}
});
});
上面的代码在 node 中。下面一个是在客户端javascript中(在视图中)。
college_model = new CollegeModel(id)
college_model.fetch({
success = function (model, res, options) {
console.log model // here , new model should come with all new attributes, but old model with only id attribute is appearing here,,,in model format.
console.log res // here, i am getting all required records in objectformat,no problem for this res
}
error = function (model, res, options) {
console.log("Error ");
}
})
谢谢