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

481
Views
TypeError: booking.populate(...).populate no es una función

Estaba creando una aplicación de back-end para programar visitas a la empresa y cuando intenté usar la función 'poblar' de Mongoose, obtuve este error:

TypeError: booking.execPopulate no es una función

No sé qué pasó, pero este es mi código:

BookingController.js

 const Booking = require('../models/Booking') module.exports = { async store(req, res) { const { user_id } = req.headers; const { spot_id } = req.params; const { date } = req.body; const booking = await Booking.create({ user: user_id, spot: spot_id, date, }); await booking.populate('spot'); await booking.populate('user'); await booking.execPopulate(); return res.json(booking); } }

BookingModel.js

 const mongoose = require('mongoose'); const BookingSchema = new mongoose.Schema({ date: String, approved: Boolean, user: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, spot: { type: mongoose.Schema.Types.ObjectId, ref: 'Spot' } }); module.exports = mongoose.model('Booking', BookingSchema);
about 4 years ago · Santiago Gelvez
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!