📜  results.push({}) nodejs 是什么意思 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:30.186000             🧑  作者: Mango

代码示例1
const mongoose = require('mongoose');
    var data = async function () {
         var array = [];
         const finalResults = await new Promise((resolve, reject) => {
            mongoose.connection.collection("organizations").find({}).toArray(function(err, result) {
              resolve(result);
           });
      });

     for(var i = 0; i < finalResults.length; i++)
     {
          var a = finalResults[i].name;
           array.push(a);
      }
        return array;
    };

    module.exports = {
        data: data,
    };