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

118
Views
Problem with mongoose schema and model typing

I want to use id, model and other fields. But I can't because reserved fields are substituted at the output, which are not described anywhere. That is, I have to guess that these fields cannot be used. How can I fix this situation? The example is copied from the official site, I just added a couple of fields.

I tried to use: interface with Document(official documentation not recommended to use),

import { Vehicle } from '~/shared/typings/vehicle'

import { Schema, model, connect } from 'mongoose'

type IUser = {
  id: string
  name: string
  model: string
  email: string
  avatar?: string
}

// 2. Create a Schema corresponding to the document interface.
const userSchema = new Schema<IUser>({
  id: { type: String, required: true },
  name: { type: String, required: true },
  model: { type: String, required: true },
  email: { type: String, required: true },
  avatar: String,
})

// 3. Create a Model.
const User = model<IUser>('User', userSchema)
const foo = await User.find()
foo.map((e) => e.id)

about 4 years ago · Juan Pablo Isaza
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!