examples/attachment-stream2.js
function addAttachment (docName, docRev) {
  const args = os.type() === 'Darwin' ? ['-l', '1'] : ['-b', '-n', '1']
  const stream = spawn('top', args).stdout
  const attName = `top-${Date.now()}.txt`
  const attContentType = 'text/plain'
  return db.addAttachment(dbName, docName, attName, docRev, attContentType, stream)
    .then(response => response.data.rev)
}
function addAttachment (docName, docRev) {
  const args = os.type() === 'Darwin' ? ['-l', '1'] : ['-b', '-n', '1']
  const stream = spawn('top', args).stdout
  const attName = `top-${Date.now()}.txt`
  const attContentType = 'text/plain'
  return db.addAttachment(dbName, docName, attName, docRev, attContentType, stream)
    .then(response => response.data.rev)
}
function addAttachment ( docName , docRev ) { const args = os . type ( ) === 'Darwin' ? [ '-l' , '1' ] : [ '-b' , '-n' , '1' ] const stream = spawn ( 'top' , args ) . stdout const attName = ` ${ Date . now ( ) } ` const attContentType = 'text/plain' return db . addAttachment ( dbName , docName , attName , docRev , attContentType , stream ) . then ( response => response . data . rev ) }
attach the output of 'top' to the document
@param {String} docName
@param {String} docRev
@return {Promise} - fulfilled with new document revision
attach the output of top to the document