FIX objectID et mauvaise collection

This commit is contained in:
Eddi3_As 2025-03-13 22:44:43 -04:00
parent 1c16e06319
commit 92699f9a83

View file

@ -107,13 +107,13 @@ class Images {
let resp = false; let resp = false;
await this.db.connect() await this.db.connect()
const conn = this.db.getConnection(); const conn = this.db.getConnection();
const imgsColl = conn.collection('files'); const quizColl = conn.collection('files');
const rgxImg = new RegExp(`/api/image/get/${imgId}`); const rgxImg = new RegExp(`/api/image/get/${imgId}`);
const result = await imgsColl.find({ userId: uid, content: { $regex: rgxImg }}); const result = await quizColl.find({ userId: uid, content: { $regex: rgxImg }}).toArray();
if(!result || result.length < 1){
if(result){ const imgsColl = conn.collection('images');
const isDeleted = await imgsColl.deleteOne({ _id: imgId }); const isDeleted = await imgsColl.deleteOne({ _id: ObjectId.createFromHexString(imgId) });
if(isDeleted){ if(isDeleted){
resp = true; resp = true;
} }