title: Hide _id from a nested document after a lookup operation
body: <p>I am trying to hide the _id value from a nested document but I am not able to achieve the proper syntax. I am always getting errors no matter how I try.</p>
  
  <p>My actual code:</p>
  
  <pre><code>db.integration.aggregate([
  {
    $match: {"integration_name" : "a-to-b" }
  },
  {
      $lookup: 
          {
              from: "service",
              localField: "from",
              foreignField: "_id",
              as: "from"
          }
  },
  {
      $lookup: 
          {
              from: "service",
              localField: "to",
              foreignField: "_id",
              as: "to"
          }
  },
  {
      $project: {
        _id: false,
        integration_name: true,
        from: { $arrayElemAt: ["$from",0]},
        to: { $arrayElemAt: ["$to",0]},
        inbound_settings: true,
        outbound_settings: true
      }
  }])
  </code></pre>
  
  <p>Actual output:</p>
  
  <pre><code>{ 
  "integration_name" : "a-to-b", 
  "inbound_settings" : {
      "pattern_matching" : "*.xml", 
      "polling_frequency" : 1000.0, 
      "backup_directory" : "/backup"
  }, 
  "outbound_settings" : {
      "pattern_matching" : "*.xml", 
      "polling_frequency" : 1000.0, 
      "backup_directory" : "/backup"
  }, 
  "from" : {
      "_id" : ObjectId("5a9821f02c669a3c40bd2a63"), 
      "name" : "a", 
      "connection_details" : {
          "protocol" : "ftp", 
          "host" : "localhost", 
          "port" : 21.0, 
          "path" : "/Users/rabobank/files/", 
          "user" : "rabobank", 
          "password" : "rabobank"
      }
  }, 
  "to" : {
      "_id" : ObjectId("5a9821e32c669a3c40bd2a62"), 
      "name" : "b", 
      "connection_details" : {
          "protocol" : "ftp", 
          "host" : "localhost", 
          "port" : 22.0, 
          "path" : "/Users/deutschebank/files/", 
          "user" : "deutschebank", 
          "password" : "deutschebank"
      }
  }}
  </code></pre>
  
  <p>Both "from" and "to" fields are nested document. What I am trying to achieve is to hide the from._id and to._id values.  </p>
  
  <p>Expected Output:</p>
  
  <pre><code>{ 
  "integration_name" : "a-to-b", 
  "inbound_settings" : {
      "pattern_matching" : "*.xml", 
      "polling_frequency" : 1000.0, 
      "backup_directory" : "/backup"
  }, 
  "outbound_settings" : {
      "pattern_matching" : "*.xml", 
      "polling_frequency" : 1000.0, 
      "backup_directory" : "/backup"
  }, 
  "from" : {
      "name" : "a", 
      "connection_details" : {
          "protocol" : "ftp", 
          "host" : "localhost", 
          "port" : 21.0, 
          "path" : "/Users/rabobank/files/", 
          "user" : "rabobank", 
          "password" : "rabobank"
      }
  }, 
  "to" : {
      "name" : "b", 
      "connection_details" : {
          "protocol" : "ftp", 
          "host" : "localhost", 
          "port" : 22.0, 
          "path" : "/Users/deutschebank/files/", 
          "user" : "deutschebank", 
          "password" : "deutschebank"
      }
  }}
  </code></pre>