javascript - 当我将数据放在 "distribuidora"字段时,我的表没有更新

标签 javascript angularjs mongodb

我的问题是我的表没有为我的字段“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;

      });;
  };

enter image description here

返回数据但表不更新

最佳答案

这是为我工作的解决方案,当我有一个对象将其转换为一个元素的数组时。如果有人需要我在这里写解决方案

  $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/

相关文章:

javascript - 点击函数内的提交函数

javascript - 无法在服务器 NodeJS 上的 Mongo 中创建用户(或基于自定义的角色)

javascript - 从另一个后端服务检索的数据(日期和时间)未正确存储在 MongoDB 中

Javascript,未捕获的类型错误 : Cannot read property "cells" of undefined

php - 循环仅插入最后一个值

javascript - 接入麦克风不带Flash

javascript - 如何使用自定义 Angular Directive(指令)包含子元素?

javascript - 我如何在 Angular JS 中按关键字搜索

javascript - 如何以 Angular 访问动态生成模型的值

javascript - 为客户取消 'One week trial' 的最佳惯例?