title: MongoDB aggregation with typescript
body: <p>I have a User model and I want to perform generic aggregation. mean any array of object I pass to this function it executes.</p>
  <p>this is the sample of getUser function</p>
  <pre><code>public async getUser(aggregate: object): Promise&lt;ResponseDTO&gt; {
       let response = {} as ResponseDTO;
       const [err, user] = await To(User.aggregate(aggregate));
       if (user) {
           response = { success: true, data: user, message: &quot;User fround&quot; };
       }
       else
           response = { success: false, message: &quot;User not fround&quot; };
       return response;
  }
  </code></pre>
  <p>and I pass this as a Parameter</p>
  <pre><code>const query = [
    {
       $match: {
          name:&quot;Jon&quot;
       }
    },
    {
      $project:{
        _id:1  
      }
    }
  ]
  const userRes = await getUser(query);
  </code></pre>
  <p>But I'm not able to run the program it's giving me syntax error on getUser function</p>
  <p>*(method) Model&lt;any, any, any&gt;.aggregate(pipeline?: any[] | undefined): Aggregate&lt;any[]&gt; (+1 overload)</p>
  <p>Argument of type 'Aggregate&lt;any[]&gt;' is not assignable to parameter of type 'Promise'.
  Type 'Aggregate&lt;any[]&gt;' is missing the following properties from type 'Promise': [Symbol.toStringTag], finally*</p>
  <p>I tried to change object to any, Array or Array in getUser parameter</p>
  <p>here is the SS of the Error <a href="https://i.stack.imgur.com/rbjEX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rbjEX.png" alt="enter image description here" /></a></p>
  <p>PS: <em><strong>I'm using node with typescript and IDE is VSCode</strong></em></p>