Fixed patch fetches to handle when the patches are targeting strings instead of ObjectIds.

This commit is contained in:
Nick Winter 2015-02-16 17:38:25 -08:00
parent 141e11f918
commit 685c3b3318

View file

@ -255,7 +255,12 @@ module.exports = class Handler
res.end()
getPatchesFor: (req, res, id) ->
query = { 'target.original': mongoose.Types.ObjectId(id), status: req.query.status or 'pending' }
query =
$or: [
{'target.original': id+''}
{'target.original': mongoose.Types.ObjectId(id)}
]
status: req.query.status or 'pending'
Patch.find(query).sort('-created').exec (err, patches) =>
return @sendDatabaseError(res, err) if err
patches = (patch.toObject() for patch in patches)