title: How to return a plain value from a Knex / Postgresql query?
body: <p>I'm trying to return a simple, scalar string value from a Postgres DB using Knex. So far, everything I do returns a JSON object with a key (the column name) and the value, so I have to reach into the object to get the value. If I return multiple rows, then I get multiple JSON objects, each one repeating the key. </p>
  
  <p>I could be returning multiple columns, in which case each row would at least need to be an array. I'm not looking for a special case where specifying a single column returns the value without the array -- I'm OK reaching into the array. I want to avoid the JSON object with the repetitive listing of column names as keys.</p>
  
  <p>I've scoured the Knex docs but don't see how to control the output.</p>
  
  <p>My table is a simple mapping table with two string columns:</p>
  
  <pre><code>CREATE TABLE public._suite
  (
      piv_id character(18) NOT NULL,
      sf_id character(18)  NOT NULL,
      CONSTRAINT _suite_pkey PRIMARY KEY (piv_id)
  )
  </code></pre>
  
  <p>When I build a query using Knex methods like </p>
  
  <pre><code>let myId = 'foo', table = '_suite';
  return db(table).where('piv_id', myId).first(['sf_id'])
                  .then( function(id) { return(id); });
  </code></pre>
  
  <p>I get <code>{"sf_id":"a4T8A0000009PsfUAE"}</code> ; what I want is just <code>"a4T8A0000009PsfUAE"</code></p>
  
  <p>If I use a raw query, like </p>
  
  <pre><code>return db.raw(`select sf_id from ${table} where piv_id = '${myId}'`);
  </code></pre>
  
  <p>I get a much larger JSON object describing the result:</p>
  
  <pre><code>{"command":"SELECT","rowCount":1,"oid":null,"rows":[{"sf_id":"a4T8A0000009Q9HUAU"}],"fields":[{"name":"sf_id","tableID":33799,"columnID":2,"dataTypeID":1042,"dataTypeSize":-1,"dataTypeModifier":22,"format":"text"}],"_parsers":[null],"RowCtor":null,"rowAsArray":false}
  </code></pre>
  
  <p>What do I have to do to just get the value itself? (Again, I'm OK if it's in an array -- I just don't want the column names.)</p>