Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Ocurrió un error al cargar los datos del archivo de colección en MongoDB usando la función toArray()

ingrese la descripción de la imagen aquí

 const express = require('express'); const app = express(); app.use(express.urlencoded({ extended: true })); const MongoClient = require('mongodb').MongoClient; app.set('view engine', 'ejs'); var db; app.listen(8080, function () { console.log('listening on 8080'); }); app.get('/', function (req, response) { response.sendFile(__dirname + '/index.html'); }); app.get('/write', function (req, response) { response.sendFile(__dirname + '/write.html'); }); app.get('/list', function (req,response) { db.collection('post').find().toArray(function(err, results){ console.log(results); }); response.render('list.ejs'); });

quiero llamar a mis datos de la colección de la base de datos mongodb.

¡pero tengo una "colección" de Typeerror indefinida!

¡por favor, ayúdame!

ingrese la descripción de la imagen aquí ¡Intenté buscar en Google y quiero mostrar mis datos al navegador!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Aquí ha importado el módulo pero no ha configurado la base de datos.

 const MongoClient = require('mongodb').MongoClient; var mongoclient = new MongoClient(new Server("localhost", 27017), {native_parser: true}); var db = mongoclient.db("COLLECTION_NAME");

Para obtener más información, consulte aquí https://mongodb.github.io/node-mongodb-native/api-generated/mongoclient.html

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!