Просмотр исходного кода

change findOne to countDocuments

Naoki427 8 месяцев назад
Родитель
Сommit
a27059d5b4
1 измененных файлов с 2 добавлено и 5 удалено
  1. 2 5
      apps/app/src/server/routes/apiv3/g2g-transfer.ts

+ 2 - 5
apps/app/src/server/routes/apiv3/g2g-transfer.ts

@@ -394,11 +394,8 @@ module.exports = (crowi: Crowi): Router => {
           logger.warn('Invalid fileSize in attachment metadata.', { fileSize });
           return res.apiv3Err(new ErrorV3('Invalid fileSize in attachment metadata.', 'invalid_metadata'), 400);
         }
-        const existingAttachment = await Attachment.findOne({
-          fileName,
-          fileSize,
-        });
-        if (!existingAttachment) {
+        const count = await Attachment.countDocuments({ fileName, fileSize });
+        if (count === 0) {
           logger.warn('Attachment not found in collection.', { fileName, fileSize });
           return res.apiv3Err(new ErrorV3('Attachment not found in collection.', 'attachment_not_found'), 404);
         }