我的问题是我的表没有为我的字段“Distribuidora”更新,但其余字段更新完美。这是我的代码,也许我在数据库中失败了,但我都试过了
我的分销商 Mongodb 代码是:
takingstats.find({ distributor: distributorAux }, { projection: {
_id: 0 } }).sort({ rank: -1 }).toArray((err, takingArray) => {
if(takingArray.length>=1){
return res.send(takingArray);
}if(takingArray.lenght==1){
return res.send(takingArray[0]);
}else{
return res.sendStatus(404);
}
});
我的 JS/Angular 代码:
$scope.busqueda = function() {
$http.get(API + "?" + $scope.valor + "=" +
$scope.valor2).then(function(response) {
if(response.data.length>1){
$scope.takingstats = response.data;
console.log("Data received: " +
JSON.stringify(response.data, null, 2));
}else{
$scope.takingstats = [response.data];
console.log("Data received: " +
JSON.stringify(response.data, null, 2));
}
}).catch(function(response) {
if (response.status == 404) {
alert("Película no encontradas para dichos " +
$scope.valor);
};
$scope.estado = response.status;
});;
};
返回数据但表不更新
最佳答案
这是为我工作的解决方案,当我有一个对象将其转换为一个元素的数组时。如果有人需要我在这里写解决方案
$scope.busqueda = function() {
$http.get(API + "?" + $scope.valor + "=" + $scope.valor2).then(function(response) {
if(response.data.length>1){
$scope.takingstats = response.data;
console.log("Data received: " + JSON.stringify(response.data, null, 2));
}else{
//here is the new statement for transf object to array
$scope.takingstats = [response.data];
console.log("Data received: " + JSON.stringify(response.data, null, 2));
}
}).catch(function(response) {
if (response.status == 404) {
alert("Película no encontradas para dichos " + $scope.valor);
};
$scope.estado = response.status;
});;
};
关于javascript - 当我将数据放在 "distribuidora"字段时,我的表没有更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55870423/