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

101
Views
Matriz de {clave: valor} en el esquema de mangosta

Tengo un campo de comments en mi interfaz y esquema de la siguiente manera

 export interface Blog extends Document { ... comments: { user: ObjectId; comment: string }[] ... } const blogSchema = new Schema<Blog>({ ... comments: [ { user: { type: ObjectId }, comment: { type: String } } ], ... })

Sin embargo, el esquema arroja este error 'ObjectId' only refers to a type but is being used as a value here. . Sé que el esquema está escrito de forma extraña, pero no sé cómo mejorar.

Lo que quiero en la base de datos es algo así como

 [ { user: "Vivid", comment: "Vivid's comment" }, { user: "David", comment: "David's comment" } ]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que necesitas cambiar ObjectId a

 mongoose.Schema.Types.ObjectId

O eso, o podrías hacer algo como:

 const mongoose = require('mongoose'); // ... other imports const { ObjectId } = mongoose.Schema.Types; // ... now use in code as `ObjectId`
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!