all files / couch/couch/database/ changes.js

87.5% Statements 14/16
83.33% Branches 5/6
100% Functions 4/4
87.5% Lines 14/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76                19×   19×                             19×   19×     19×         19×   19×                                       17× 17×         26×       24× 24×          
import SuspendableChanges from '../changes/suspendable-changes';
import stringifyUnlessEmpty from '../../util/stringify-unless-empty';
 
export default SuspendableChanges.extend({
 
  database: null,
 
  _feedOptions() {
    let opts = this.get('opts');
 
    let {
      since,
      view,
      filter,
      include_docs,
      conflicts,
      style,
      timeout,
      attachments,
      heartbeat,
      doc_ids,
      descending,
      reconnect
    } = opts;
 
    view = view || undefined;
 
    if(view) {
      filter = '_view';
    }
 
    Iif(doc_ids) {
      view = undefined;
      filter = '_doc_ids';
    }
 
    let url = this.get('database.url');
 
    return {
      url: `${url}/_changes`,
      since,
      reconnect,
      qs: {
        include_docs,
        conflicts,
        style,
        timeout,
        attachments,
        heartbeat,
        descending,
        doc_ids: stringifyUnlessEmpty(doc_ids),
        view,
        filter
      }
    };
  },
 
  _feedContext() {
    let couch = this.get('database.couch');
    return {
      request: opts => couch._request(opts)
    };
  },
 
  _feedFactoryName(feed) {
    return `couch:database-changes/feed/${feed}`;
  },
 
  willDestroy() {
    this.get('database')._changesWillDestroy(this);
    this._super();
  }
 
});