title: How to print full query output in console
body: <p>I am writing mongodb aggreagation query in nodejs. I tried my best to figure it out, but the codes won't work in my method. How to print full query output in console</p>
  <pre><code>    const { MongoClient, ObjectId } = require('mongodb');
      
      async function main(){
      
          const uri = `mongodb://${dbUser}:${dbPassword}@${ipAddress}:${port}/${dbName}`;
      
          const client = new MongoClient(uri);
      
          try {
      
              await client.connect();
      
              await printStudents(client,&quot;541516516165164489d3aee&quot;);
      
          } finally {
              await client.close();
          }
      }
      
      main().catch(console.error);
      
      /**
       * Print the students for a given schoolId
       * @param {MongoClient} client A MongoClient that is connected to a cluster with the education database
       * @param {ObjectId} schoolId
       */
      
      async function printStudents(client,schoolId){
          const pipeline = [
              { 
                  '$match' : { '_id' : ObjectId(schoolId) } 
              },
              {
                '$project': 
                {
                  '_id':  { '$toString': '$_id'}
                }
              },
              {
                  '$lookup':
                  {
                      'from': 'students',
                      'localField': '_id',
                      'foreignField': 'schools',
                      'as': 'Students'
                  }
              }
          ]; 
      
          const docs = client.db(&quot;education&quot;).collection(&quot;schools&quot;).aggregate(pipeline).toArray();
      console.log(docs);
  
      }
  </code></pre>
  <p>I hope I get some good advice on how to tackle the problem properly. :)</p>