arashsheyda / nuxt-mongoose

A Nuxt module for simplifying the use of Mongoose in your project.
https://docs.arashsheyda.me/nuxt-mongoose
76 stars 14 forks source link

feat: add discriminator helper #47

Closed jbool24 closed 7 months ago

jbool24 commented 9 months ago

Allow extension and inheritance of base models with discriminator models.

arashsheyda commented 9 months ago

@jbool24 thanks for this! this is such a good idea. but do you think we can have it in the defineMongooseModel as an optinal param? like:

return baseModel ? baseModel!.discriminator<T>(name, newSchema) : mongoose.model<T>(name, newSchema)
jbool24 commented 9 months ago

@arashsheyda I don't have a good reason why not. But I was just trying to keep things separated instead of using internal flags to manipulate what the factory outputs. Your lib, your choice :smiley: :+1:

arashsheyda commented 8 months ago

@jbool24 sorry for late reply, I think becuase they share a lot of similarities it's better to do it that way.

ps. it's an open source lib so we can talk about it :) it's not my choice only

jbool24 commented 8 months ago

@arashsheyda In that case :smile:, my two-cents is keeping the two factories discrete from each other because...

I'm open to hear why combining them would be good also.

arashsheyda commented 8 months ago

@jbool24 well here are my thoughts for having it as Combined Factory Function:

but as you said having it as Separate Factory Functions has it own pros too!

🤔

RodrigoRoy commented 7 months ago

As a regular (not so specialized) Mongoose user, I prefer the ideas for a Separate Factory Functions. I just want a new function that allow me to create a Discriminator, otherwise, I aggree that it is kind of confusing.

arashsheyda commented 7 months ago

@jbool24 thank you!