From 685c3b3318b8dd6b6c4ebfc323de5ad77d3b9538 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Mon, 16 Feb 2015 17:38:25 -0800 Subject: [PATCH] Fixed patch fetches to handle when the patches are targeting strings instead of ObjectIds. --- server/commons/Handler.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/commons/Handler.coffee b/server/commons/Handler.coffee index e296fb033..b71d3b737 100644 --- a/server/commons/Handler.coffee +++ b/server/commons/Handler.coffee @@ -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)