title: Rxjs Map Array in Json Document to new Array type
body: <p>I am retrieving a document from PouchDB in an Angular Service.  The document is retrieved in the following format:</p>
  
  <pre><code>{
  "_id":"segments",
  "_rev":"1-4f0ed65cde23fe724db13bea1ae3bb13",
  "segments":[
      { "name":"Aerospace" },
      { "name":"Auto repair" },
      { "name":"Commercial" },
      { "name":"Education" },
      { "name":"Energy" },
      { "name":"Farm/ranch" },
      { "name":"Furniture" },
      { "name":"Heavy Equipment" },
      { "name":"Hobbyist" },
      { "name":"Infrastructure" },
      { "name":"Luxury/Leisure" },
      { "name":"Military" },
      { "name":"MUP" },
      { "name":"Processing" },
      { "name":"Rail" },
      { "name":"Transportation" }
  ]}
  </code></pre>
  
  <p>And I want to map that to a new Array that would look like:</p>
  
  <pre><code>[
    { value: "Aerospace", viewValue: "Aerospace" },
    { value: "Auto Repair", viewValue: "Auto Repair" },
    { value: "Commercial", viewValue: "Commercial" }
    ...
   ]
  </code></pre>
  
  <p>To accomplish this, I have tried this code in my Service:</p>
  
  <pre><code>getSegments(): Observable&lt;any[]&gt; {
    return from(this.database.get('segments'))
    .pipe(
      map((results) =&gt; results.segments)
    );
  }
  </code></pre>
  
  <p>And I transform the array in my Component like this:</p>
  
  <pre><code>segments: SegmentsLookup[] = [];
  ...
  this.lookupDbService.getSegments()
    .subscribe(data =&gt; {
      data.forEach(element =&gt; {
        this.segments.push({value: element.name, viewValue: element.name});
    });
  });
  </code></pre>
  
  <p>This works but I know there is a way to map this properly back in the Service code.  Also, when done this way, the compiler complains about the "results.<em>segments</em>" stating "Property "segments" does not exist on type '{}'.</p>
  
  <p>How do I map the data retrieved to the Array that I need in the Service's "getSegments" method?  </p>