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

425
Views
`Usuario` no es un tipo válido en la ruta `ref`

No pude encontrar un error, ¿alguien puede ayudarme con esto? No entiendo cuál es el error aquí.

**Configuración de esquema no válida: User no es un tipo válido en la ref de la ruta.

Esquema de lista de coincidencias

 const mongoose = require('mongoose'); const Schema = mongoose.Schema; const {ObjectId} = mongoose.Schema; const match = new Schema({ type: ObjectId, ref:'User' },{ timestamp:true }); const matchList = new Schema({ user:{ type: ObjectId, ref:'User' }, matches:[match] },{ timestamp:true }); const MatchList = mongoose.model('Match',matchList); module.exports = MatchList;

esquema de usuario

 var mongoose = require('mongoose'); var Schema = mongoose.Schema; var UserSchema = new Schema({ firstname:{ type:String, required:true }, lastname:{ type:String, required:true }, email:{ type:String, required:true, unique:true }, imgUrl:{ type:String }, age:{ type:Number, required:true, min:16 }, gender:{ type:String, required:true }, place:{ type:String, } },{ timestamp:true }); const User = mongoose.model('User',UserSchema); module.exports = User;
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Solución

Su UserSchema está totalmente bien. Pero, cometió un error en su código MatchList Schema en la line 5 . Aquí está la solución:

Esquema de lista de coincidencias

 const mongoose = require('mongoose'); const Schema = mongoose.Schema; const { ObjectId } = mongoose.Schema const match = new Schema({ user: { // <-- You didn't put variable name here before. type: ObjectId, ref: 'User' } }, { timestamp: true }); const matchList = new Schema({ user: { type: ObjectId, ref: 'User' }, matches: [match] }, { timestamp: true }); const MatchList = mongoose.model('Match', matchList); module.exports = MatchList;
over 4 years ago · Santiago Trujillo 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!