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

263
Views
Mongoose - model.find no es una función

este es muy extraño y no entiendo muy bien por qué no funciona. Tengo 2 funciones, una para agregar un elemento a una colección MongoDB. Eso está funcionando bien. Tengo otra función que está destinada a buscar en la colección elementos que coincidan con mi consulta. Por alguna razón, la función de búsqueda devuelve "no es una función" y me pregunto si alguien puede ayudar.

Cuando intento llamar a findSimilarEvents() obtengo TypeError: event.find is not a function en la consola

Mi modelo:

 var mongoose = require('mongoose'); const eventSchema = new mongoose.Schema({ eventTime: { type: Date, default: Date.now() }, eventLoggedFrom: String, eventData: Object, eventID: String, ticketID: { type: String, default: "" }, ticketStatus: { type: String, default: "" }, eventLastUpdated: { type: Date, default: Date.now() }, }) module.exports = mongoose.model('event', eventSchema);

Mi función de trabajo:

 exports.addEventToDB = async function(eventData, eventLoggedFrom, EventID) { const event = new EventModel({ eventLoggedFrom: eventLoggedFrom, eventData, // this is a JSON object eventID: eventID }); await event.save(); }

Mi función que no funciona:

 exports.findSimilarEvents = async function(eventData, eventLoggedFrom) { const event = new EventModel(); let similarEvents = await event.find({ eventData: eventData }); for (var i = 0; i = similarEvents.length; i++) { console.log("found similar event"); console.log(similarEvents[i]); } }

¡Estoy feliz de proporcionar cualquier otra información si alguien tiene alguna idea!

Gracias de antemano

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

0

 exports.findSimilarEvents = async function(eventData, eventLoggedFrom) { let similarEvents = await EventModel.find({ eventData: eventData }); for (var i = 0; i = similarEvents.length; i++) { console.log("found similar event"); console.log(similarEvents[i]); } }

prueba esto ...

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!