     saveLocal: (doc) ->
       _funcName = _indent + "storage.saveLocal"
       console.log _funcName
-      @_save doc, true
+      @_save doc
 
     saveRemoteOnly: (doc) ->
       _funcName = _indent + "storage.saveRemoteOnly"
       console.log _funcName
-      @_save doc, false
+      @_save doc
 
     save: (doc) ->
-      @_save(doc, true)
+      @_save(doc)
 
     del: (doc) ->
       deletedDoc = {_id: doc._id, _rev: doc._rev, _deleted: true}
-      @saveLocal(deletedDoc).catch =>
-        @saveRemoteOnly(deletedDoc)
+      @save(deletedDoc)
 
     queryRemote: (fun, options) ->
       deferred = $q.defer()

  dbUrl = $location.absUrl().split('#')[0]
  dbUrl += 'lupo-proto/'
  remoteDb = new PouchDB(dbUrl)
  localDb = new PouchDB('lupo-proto')
  #TMP
  PouchDB.replicate(localDb, remoteDb)
  #.on('change', (e) -> console.log(e))
  #.on('complete', (e) -> console.log(e))
  #.on('error', (e) -> console.error(e))

  _indent = "  "
  {
    get: (_id) ->
      _funcName = _indent + "storage.get"
      console.log _funcName, _id
      deferred = $q.defer()
      otherOneFailed = false
      remoteDb.get _id, (err, result) =>
        if err?
          console.error "remote", err
          if otherOneFailed
            deferred.reject err
          otherOneFailed = true
        else
          deferred.resolve result
      localDb.get _id, (err, result) =>
        if err?
          console.error "local", err
          if otherOneFailed
            deferred.reject err
          otherOneFailed = true
        else
          deferred.resolve result
      return deferred.promise

    _save: (doc, remoteAndLocal) ->
      deferred = $q.defer()
      if doc._id?
        method = "put"

      _funcName = _indent + "query"
      console.log _funcName, fun, options
      deferred = $q.defer()
      otherOneFailed = false
      remoteDb.query fun, options, (err, result) =>
        if result.rows.length == 0
          deferred.resolve []
        else
          deferred.resolve (doc.value for doc in result.rows)
      return deferred.promise
