Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

743
Vistas
Mongoose ObjectId not matched in typescript

I defined an interface using mongoose.

import {Types} from 'mongoose'    

export interface IShop {  
  readonly center: Types.ObjectId;    
}


async create(data):Promise<IShop>{
   const result = await new this.model(data).save
   return result
}

And there is a shcema as below.

 {
   center: mongoose.Schema.Types.ObjectId
 }

But this gives an error of type saying

Error:(18, 5) TS2322: Types of property 'center' are incompatible. Type 'ObjectId' is missing the following properties from type 'ObjectId': generationTime, equals, getTimestamp, toHexString

But when I define mongoose.Schema.Types.ObjectId in interface it matches well. But I have to use Types.ObjectId for making new Types.ObjectId(string) in somewhere.

Could you help me some advice for this?

I use mongoose 5.11.9 and I dont' use @types/mongoose.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda