Mongodb 如何使用数据库中的值查询mongo数据库?
使用angular2和meteor,使用以下数据: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"
{ "_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" }
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
}
}
]
);
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
}
}
]
);
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
}
}
]
);
});
}]);
}
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
}
}
]
);
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对象?