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

735
Views
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
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!