How do i send array values from angular controller to node and using that array values i have to search result from mongoDB
<p>I am sending array values from angular controller to node, that is look like following [ '5732c95d599bfcc031013929', '5732c8e6599bfcc031013925' ] using this value i have to search result that matches both id in mongoDB. So i don't know how to write query for this.</p>

<h2>controller.js</h2>

<pre><code>$http({
            url: 'http://192.168.2.8:7200/api/manage-product',
            method: 'POST',
            data: {userId:vm.uid, code:vm.purchased, code1:vm.contributed}
        }).success(function(res) {
            //$scope.productlist = res;
            vm.result = res.result;
            console.log(vm.result);
            vm.count=vm.result.length;
            //console.log(vm.count + "New")

            vm.showPurchaserInfo = false;
            vm.showMessage = false;

            vm.info=[];
            vm.info[0]=vm.result[0]._id;
            vm.info[1]=vm.result[1]._id;

            if($scope.selectedCode == 2 || 3){
                if(vm.count &gt;= 1 ){
                    $http({
                        url: 'http://192.168.2.8:7200/api/purchaserInfo',
                        method: 'GET',
                        params: {"proID" : vm.info}
                    }).success(function(res) {
                        vm.purchasedPeople = res.result;
                        console.log(vm.purchasedPeople);

                        if($scope.selectedCode == 2){
                            vm.showPurchaserInfo = true;
                        } else {
                            vm.showPurchaserInfo = false;
                        }
                    }, function(error) {
                        console.log(error);
                        alert('here');
                    });
                } else {
                    vm.result = res.result;
                    vm.count=vm.result.length;
                    console.log(vm.count);
                    if(vm.count == 0){
                        vm.showMessage = true;
                    } else {
                        vm.result=res.result;   
                        vm.showMessage = false; 
                    }
                }
            }
            //console.log(vm.result);
            //vm.docs=res.docs;
        }, function(error) {
            console.log(error);
            alert('here');
        });
    };
</code></pre>

<p>In the above code i am sending params of proID contains [ '5732c95d599bfcc031013929', '5732c8e6599bfcc031013925' ] this value to node.</p>

<h2>node.js</h2>

<pre><code>router.get('/purchaserInfo',function(req,res){
    console.log(req.query.proID);
    var pId = req.query.proID;
    var findPurchaserInfo = function(db, callback) {
        var cursor =db.collection('purchased').find({purchasedItemID:pId}).toArray(function(err, docs){
            if(err){  
                callback(new Error("Some problem"));
            }else{
                callback(null,docs);
            } 
        });
    };

    MongoClient.connect(url, function(err, db) {
        assert.equal(null, err);
        findPurchaserInfo(db, function(err,docs) {
            db.close();
            if(err) return res.json({result:null})
            else
            return res.json({result: docs});
        });
    });     
});
</code></pre>

<p>In this node the value pId contains that array i had sent from angular controller. In the query it takes only first value of array and throw the result of that, but second one is not using.</p>

<p>mongoDb collection is look like following.</p>

<p><code>{
   "_id": ObjectId("5733397f3e102e40365bb5de"),
   "quantity": "1",
   "store": "amazon",
   "purchasedPerson": "Admin",
   "email": "admin@gmail.com",
   "message": "I purchased this item for you",
   "terms": "yes",
   "purchasedItemID": "5732c95d599bfcc031013929",
   "purchasedDate": "2016-05-11T13:53:45.606Z",
   "ownerId": "56fe44836ce2226431f5388f" 
}</code></p>

<p>and</p>

<p><code>{
   "_id": ObjectId("5733006ace25b9682abb7c89"),
   "quantity": "1",
   "store": "amazon",
   "purchasedPerson": "vinay",
   "email": "vinay@gmail.com",
   "message": "I purchased this item for you",
   "terms": "yes",
   "purchasedItemID": "5732c8e6599bfcc031013925",
   "purchasedDate": "2016-05-11T09:50:17.718Z",
   "ownerId": "56fe44836ce2226431f5388f" 
}</code></p>

<p><a href="http://i.stack.imgur.com/amgC5.jpg" rel="nofollow">screenshot after $in operator use</a></p>

<h2>from.html</h2>

<pre><code>&lt;md-content  &gt;  
&lt;div class="md-padding"  layout="row"  layout-wrap &gt;
    &lt;md-card  ng-repeat="product in vm.result | filter:searchText" flex="40"&gt;
        &lt;md-card-header&gt;
            &lt;md-card-header-text&gt;
                &lt;span class="md-title"&gt;{{ product.Product_Name }}&lt;/span&gt;
            &lt;/md-card-header-text&gt;
        &lt;/md-card-header&gt;
        &lt;img ng-src="{{ product.Image }}" class="md-card-image" alt="Image here"&gt;
        &lt;md-card-title&gt;
            &lt;md-card-title-text&gt;
                &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Brand:&lt;/span&gt;  {{ product.Brand }}&lt;/span&gt;
                &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Price: &lt;/span&gt;  {{ product.Price }}&lt;/span&gt;
                &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Capasity/Color:&lt;/span&gt;  {{ product.Color }}&lt;/span&gt;
                &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Url: &lt;/span&gt;  &lt;a href="{{ product.Url }}" target="_blank" &gt;{{ product.Url | characters:100}}&lt;/a&gt;&lt;/span&gt;
                &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Category: &lt;/span&gt;  {{ product.Category }}&lt;/span&gt;
                &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Description: &lt;/span&gt;  {{ product.Description | characters:100}}&lt;/span&gt;
            &lt;/md-card-title-text&gt;
        &lt;/md-card-title&gt;

        &lt;div class="" ng-repeat="info in vm.purchasedPeople" ng-show="vm.showPurchaserInfo"&gt;
            &lt;span layout="row"&gt;&lt;hr flex/&gt;&lt;/span&gt;
            &lt;md-card-title &gt;
                &lt;md-card-title-text &gt;
                    &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Purchased By:&lt;/span&gt; {{info.purchasedPerson}} &lt;/span&gt;
                    &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Store:&lt;/span&gt; {{info.store}} &lt;/span&gt;
                    &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Purchased Date:&lt;/span&gt; {{info.purchasedDate | date:"MM/dd/yyyy 'at' h:mma"}} &lt;/span&gt;
                    &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Guest's Note:&lt;/span&gt; {{info.message}} &lt;/span&gt;
                    &lt;span&gt;&lt;span class="md-subhead" style="font-weight: bold; padding:2px;"&gt;Purchase Quantity:&lt;/span&gt; {{info.quantity}} &lt;/span&gt;
                &lt;/md-card-title-text&gt;
            &lt;/md-card-title&gt;
        &lt;/div&gt;

        &lt;md-card-actions layout="row" layout-align="end center"&gt;
            &lt;md-button class="send-button md-accent md-raised" ng-click="vm.editDialog($index,product._id)"&gt;Edit&lt;/md-button&gt;
            &lt;md-button name="ProductId" class="send-button md-accent md-raised" ng-click="remove(product._id,'{{$index}}')"&gt;Remove&lt;/md-button&gt;
        &lt;/md-card-actions&gt;
      &lt;/md-card&gt;
</code></pre>

<p></p>