all files / documents/adapter/ couch.js

90% Statements 9/10
100% Branches 0/0
75% Functions 3/4
88.89% Lines 8/9
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                                                  122×          
import Ember from 'ember';
import Adapter from './adapter';
 
const {
  getOwner,
  computed
} = Ember;
 
const couch = () => computed('url', function() {
  let couches = getOwner(this).lookup('couch:couches');
  let opts = this.getProperties('url');
  return couches.couch(opts);
}).readOnly();
 
export default Adapter.extend({
 
  couch: couch(),
 
  url: null,
 
  storeDocuments() {
    return this.get('couch');
  },
 
  databaseDocuments(database) {
    let identifier = database.get('identifier');
    return this.get('couch').database(identifier);
  }
 
}).reopenClass({
 
  identifierFor(opts) {
    return `couch-${opts.url}`;
  }
 
});