title: promise all several mongodb aggregate
body: <p>i would like to promise all several mongodb aggregate</p>
  <p><code>AllPromises</code> = an array with promises <em>(if I'm not wrong)</em></p>
  <pre><code>  const AllPromises = []
    for (
      let i = 0;
      i &lt; SIZE;
      i++
    ) {
      const promise = () =&gt; {
        try {
          return client
            .db(DATABASE)
            .collection('collectionName')
            .aggregate([...])
            .toArray()
         } catch (err) {
          console.error('Error', err)
          return []
        }
      }
      allPromises.push(promise)
    }
  
    const resolvedPromises = await Promise.all(allPromises).flat()
  
    console.log(resolvedPromises)
  </code></pre>
  <p><strong>expected result</strong>: array of documents
  But I get  <code>[[Function: promise], ...]</code></p>