francescov1 / mongoose-tsgen

A plug-n-play Typescript generator for Mongoose.
105 stars 25 forks source link

Field with same starting name in mongoose model schema is ignored #70

Closed IamAfnanSk closed 3 years ago

IamAfnanSk commented 3 years ago
const GitHubInfo = new mongoose.Schema({
    login: String,
    id: Number,
    node_id: String
})

const UserSchema = new mongoose.Schema(
    {
        name: { type: String, required: true },
        github: GitHubInfo,
        githubProfileURL: { type: String, default: '' },
        twitterProfileURL: { type: String, default: '' }
    },
    { collection: 'users' }
)

In this schema there are 2 fields gihub and githubProfileURL but after generating types with mongoose-tsgen, githubProfileURL is skipped and all other fields are typed in the output file.

francescov1 commented 3 years ago

@IamAfnanSk Realized this actually broke a specific case where the generator handles nested properties (need to consider keys like city.address.country, which isnt handled by your fix. I created a second PR for this, can you verify if your issue is fixed by this change? https://github.com/francescov1/mongoose-tsgen/pull/72/files#diff-0031f10c8304cb81d02e83ba1b26c8f9273cc02fea992e27df58ea2abc63074eR205

IamAfnanSk commented 3 years ago

@francescov1 Hey! I didn't thought about that. Also yes PR #72 works with this issue's condition too. Lets' publish the new version. 💪🏼

francescov1 commented 3 years ago

Published in 8.4.2 🚀