From c70c0bb96dfa75d8a28c8b76b52cde94cff4e487 Mon Sep 17 00:00:00 2001 From: ingalls Date: Tue, 19 Dec 2023 13:22:33 -0700 Subject: [PATCH] Add toString for id comparison --- src/api/db/models/Image.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/db/models/Image.js b/src/api/db/models/Image.js index 25c256a0..64426b39 100644 --- a/src/api/db/models/Image.js +++ b/src/api/db/models/Image.js @@ -326,7 +326,7 @@ export class ImageModel { try { const image = await ImageModel.queryById(input.imageId, context); - const comment = (image.comments || []).filter((c) => { return c._id === input.id; })[0]; + const comment = (image.comments || []).filter((c) => { return c._id.toString() === input.id.toString(); })[0]; if (!comment) throw new Error('Comment not found on image'); if (comment.author !== context.user['cognito:username'] && !context.user['is_superuser']) { @@ -349,7 +349,7 @@ export class ImageModel { try { const image = await ImageModel.queryById(input.imageId, context); - const comment = (image.comments || []).filter((c) => { return c._id === input.id; })[0]; + const comment = (image.comments || []).filter((c) => { return c._id.toString() === input.id.toString(); })[0]; if (!comment) throw new Error('Comment not found on image'); if (comment.author !== context.user['cognito:username'] && !context.user['is_superuser']) {