我在MongoDB中有用户和包裹。每个用户都有包裹。我想获得注册用户的包裹,并将其推送到Beanstalkd。我的问题
User.find({
'purchaseID':{$ne:null},
'isEnabled':true,
$and: [
{ $or: [
{'purchaseDate':{$lte:new Date('2012-07-10T00:00:00.000Z')}}, //old Users
{'purchaseDate':{$gte: moment().subtract(1,'years')}} //new Users with expiryDate
]}
]
})
.exec(function(err,users) {
users.forEach(function(user) {
Parcel.find({'owner':user.id,'isDelivered':false,'startDate':{$gt:moment().subtract(1,'months')}})
.select('owner trackingNumber slug')
.exec(function(err,parcels) {
parcels.forEach(function(parcel) {
//push it to beanstalkd
console.log(parcel);
});
})
});
});