fix: Corregir scroll del emulador y serializacion circular de FindCursor en mongosh

This commit is contained in:
2026-08-12 03:35:41 +00:00
parent 827db0a356
commit c06ca1db79
2 changed files with 10 additions and 4 deletions
+8 -2
View File
@@ -828,8 +828,14 @@ app.post('/api/admin/mongosh', async (req, res) => {
})();
`);
const result = await evalFn(dbProxy, ObjectId);
res.json({ result });
let finalResult = await evalFn(dbProxy, ObjectId);
// Si el resultado es un cursor de MongoDB (ej. db.collection.find()), lo convertimos a array
if (finalResult && typeof finalResult === 'object' && typeof finalResult.toArray === 'function') {
finalResult = await finalResult.toArray();
}
res.json({ result: finalResult });
} catch (err) {
res.status(400).json({ error: err.message || String(err) });
}