Skip to content

Commit

Permalink
fix: adjust for [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Jun 6, 2016
1 parent ff997fe commit 3ddc6bb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions helpers/add-one.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'

var PouchDBErrors = require('pouchdb-errors')
var Promise = require('lie')

var toDoc = require('../utils/to-doc')
var addTimestamps = require('../utils/add-timestamps')

module.exports = function addOne (object) {
var Promise = this.constructor.utils.Promise
var errors = this.constructor.Errors

if (typeof object !== 'object') {
return Promise.reject(errors.NOT_AN_OBJECT)
return Promise.reject(PouchDBErrors.NOT_AN_OBJECT)
}

var method = object.id ? 'put' : 'post'
Expand Down
13 changes: 8 additions & 5 deletions helpers/find-or-add-one.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
module.exports = findOrAddOne

var PouchDBErrors = require('pouchdb-errors')
var Promise = require('lie')

var toId = require('../utils/to-id')
var findOne = require('./find-one')
var addOne = require('./add-one')
var eventify = require('./eventify')

module.exports = function findOrAddOne (state, idOrObject, newObject) {
function findOrAddOne (state, idOrObject, newObject) {
var self = this
var Promise = this.constructor.utils.Promise
var errors = this.constructor.Errors
var id = toId(idOrObject)

if (!id) {
return Promise.reject(errors.MISSING_ID)
return Promise.reject(PouchDBErrors.MISSING_ID)
}

if (idOrObject === id && !newObject) {
return Promise.reject(errors.MISSING_ID)
return Promise.reject(PouchDBErrors.MISSING_ID)
}

return findOne.call(this, id)
Expand Down
4 changes: 2 additions & 2 deletions helpers/update-many.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

var extend = require('pouchdb-extend')
var PouchDBErrors = require('pouchdb-errors')

var changeObject = require('../utils/change-object')
var toDoc = require('../utils/to-doc')
Expand All @@ -11,7 +12,6 @@ var findMany = require('./find-many')

module.exports = function updateMany (array, change) {
var self = this
var errors = this.constructor.Errors
var objects
var ids = array.map(toId)

Expand All @@ -33,7 +33,7 @@ module.exports = function updateMany (array, change) {
return object
}
if (typeof passedObject !== 'object') {
return errors.NOT_AN_OBJECT
return PouchDBErrors.NOT_AN_OBJECT
}
return extend(object, passedObject)
})
Expand Down
6 changes: 3 additions & 3 deletions helpers/update-one.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'

var extend = require('pouchdb-extend')
var PouchDBErrors = require('pouchdb-errors')
var Promise = require('lie')

var changeObject = require('../utils/change-object')
var toDoc = require('../utils/to-doc')
Expand All @@ -10,12 +12,10 @@ var findOne = require('./find-one')

module.exports = function updateOne (idOrObject, change) {
var self = this
var Promise = this.constructor.utils.Promise
var errors = this.constructor.Errors
var object

if (typeof idOrObject === 'string' && !change) {
return Promise.reject(errors.NOT_AN_OBJECT)
return Promise.reject(PouchDBErrors.NOT_AN_OBJECT)
}

return findOne.call(this, idOrObject)
Expand Down
7 changes: 2 additions & 5 deletions update-all.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use strict'
module.exports = updateAll

var extend = require('pouchdb-extend')
var Promise = require('lie')

var toObject = require('./utils/to-object')
var toDoc = require('./utils/to-doc')
var addTimestamps = require('./utils/add-timestamps')
var isntDesignDoc = require('./utils/isnt-design-doc')

module.exports = updateAll

/**
* updates all existing objects
*
Expand All @@ -17,8 +16,6 @@ module.exports = updateAll
* @return {Promise}
*/
function updateAll (changedProperties) {
var Promise = this.constructor.utils.Promise

var type = typeof changedProperties
var objects

Expand Down
8 changes: 4 additions & 4 deletions update.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'
module.exports = update

var Promise = require('lie')

var updateOne = require('./helpers/update-one')
var updateMany = require('./helpers/update-many')

module.exports = update

/**
* updates existing object.
*
Expand All @@ -15,7 +15,7 @@ module.exports = update
*/
function update (objectsOrIds, change) {
if (typeof objectsOrIds !== 'object' && !change) {
return this.constructor.utils.Promise.reject(
return Promise.reject(
new Error('Must provide change')
)
}
Expand Down

0 comments on commit 3ddc6bb

Please sign in to comment.