Monday 10 April 2017

How to concatenate the length of two collections in mongodb and get the total length of two collections in one variable?

Below is my code.i need to get the total length of two collections in single variable.

audiofiles.find(),function(err,res){
                console.log(res.length);
                var count1 = res.length;
            }
            videofiles.find(),function(err,res){
                console.log(res.length);
                var count2 = res.length;
            }
            var totalcount = parseInt(count1+count2);
            console.log(totalcount);



via Jagadeesh

No comments:

Post a Comment