Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mongodb 如何使用数据库中的值查询mongo数据库?_Mongodb_Angular - Fatal编程技术网

Mongodb 如何使用数据库中的值查询mongo数据库?

Mongodb 如何使用数据库中的值查询mongo数据库?,mongodb,angular,Mongodb,Angular,使用angular2和meteor,使用以下数据: { "_id" : "DxEraKtfYavoukdCK", "name" : "Aaron", "capacity" : 20, "available_capacity" : 15, "location" : "1" } { "_id" : "yMhEggaGmS7iio9P4", "name" : "Benard", "capacity" : 20, "available_capacity" : 20, "location" : "2"

使用angular2和meteor,使用以下数据:

{ "_id" : "DxEraKtfYavoukdCK", "name" : "Aaron", "capacity" : 20,  "available_capacity" : 15, "location" : "1" }
{ "_id" : "yMhEggaGmS7iio9P4", "name" : "Benard", "capacity" : 20,  "available_capacity" : 20, "location" : "2" }
{ "_id" : "TTD2wedGYWaLctJHt", "name" : "Candy", "capacity" : 50, "available_capacity" : 15, "location" : "3" }
  • 如何找到容量-可用容量>10的工人

  • db.collection('workers').find({"capacity": {$gt: 10}}).toArray(function (err, res)    
    {
          if (err) throw err;
          console.log(res);
    });
    
  • 如何找到具有可用容量>=容量的工人

  • db.collection('workers').aggregate(
    [
      {
       $project:
          {
            _id: 1,
            name: 1,
            capacity:1,
            capacity_available: { $gte: $capacity},
            location: 1
          }
        }
      ]
    );
    
  • 如何找到容量-可用容量>10的工人

    db.collection('workers').find({"capacity": {$gt: 10}}).toArray(function (err, res)    
    {
          if (err) throw err;
          console.log(res);
    });
    
  • 如何找到具有可用容量>=容量的工人

    db.collection('workers').aggregate(
    [
      {
       $project:
          {
            _id: 1,
            name: 1,
            capacity:1,
            capacity_available: { $gte: $capacity},
            location: 1
          }
        }
      ]
    );
    
  • 更新

    我刚刚用完了其他教程。我认为这个概念是一样的

    Q1

    Workers = new Mongo.Collection('workers');
    
    if (Meteor.isClient) {
    
      // This code only runs on the client
      angular.module('simple-todos',['angular-meteor']);
    
      angular.module('simple-todos').controller('TodosListCtrl', ['$scope', '$meteor',
        function ($scope, $meteor) {
    
          $scope.findWorkers = $meteor.collection( function() {
            return Workers.find({"capacity": {$gt: 10}});
          });
    
        }]);
    }
    
    Q2

    我不知道你要在这里工作。猜猜看

    Workers = new Mongo.Collection('workers');
    
    if (Meteor.isClient) {
    
      // This code only runs on the client
      angular.module('simple-todos',['angular-meteor']);
    
      angular.module('simple-todos').controller('TodosListCtrl', ['$scope', '$meteor',
        function ($scope, $meteor) {
    
          $scope.findWorkers = $meteor.collection( function() {
            return Workers.aggregate(
            [
               {
                  $project:
                   {
                     _id: 1,
                     name: 1,
                     capacity:1,
                     capacity_available: { $gte: $capacity},
                     location: 1
                   }
               }
             ]
            );
          });
        }]);
    }
    
  • 如何找到容量-可用容量>10的工人

    db.collection('workers').find({"capacity": {$gt: 10}}).toArray(function (err, res)    
    {
          if (err) throw err;
          console.log(res);
    });
    
  • 如何找到具有可用容量>=容量的工人

    db.collection('workers').aggregate(
    [
      {
       $project:
          {
            _id: 1,
            name: 1,
            capacity:1,
            capacity_available: { $gte: $capacity},
            location: 1
          }
        }
      ]
    );
    
  • 更新

    我刚刚用完了其他教程。我认为这个概念是一样的

    Q1

    Workers = new Mongo.Collection('workers');
    
    if (Meteor.isClient) {
    
      // This code only runs on the client
      angular.module('simple-todos',['angular-meteor']);
    
      angular.module('simple-todos').controller('TodosListCtrl', ['$scope', '$meteor',
        function ($scope, $meteor) {
    
          $scope.findWorkers = $meteor.collection( function() {
            return Workers.find({"capacity": {$gt: 10}});
          });
    
        }]);
    }
    
    Q2

    我不知道你要在这里工作。猜猜看

    Workers = new Mongo.Collection('workers');
    
    if (Meteor.isClient) {
    
      // This code only runs on the client
      angular.module('simple-todos',['angular-meteor']);
    
      angular.module('simple-todos').controller('TodosListCtrl', ['$scope', '$meteor',
        function ($scope, $meteor) {
    
          $scope.findWorkers = $meteor.collection( function() {
            return Workers.aggregate(
            [
               {
                  $project:
                   {
                     _id: 1,
                     name: 1,
                     capacity:1,
                     capacity_available: { $gte: $capacity},
                     location: 1
                   }
               }
             ]
            );
          });
        }]);
    }
    

    如何获取angularjs meteor中的db对象?如何获取angularjs meteor中的db对象?