function with paramater, result return in js
- var rest = [];
- function queryCollection(collection, callback){
- collection.find({},{'collection':1}).toArray(function(err, result) {
- if (err) {
- console.log(err);
- } else if (result.length > 0) {
- rest.push(result);
- callback();
- }
- });
- }
- queryCollection(collection, function(){
- console.log(rest);
- });
input collection, output rest
Nhận xét
Đăng nhận xét