Skip to content

creating collections from same class #668

Answered by hasezoey
aster2709 asked this question in Q&A
Discussion options

You must be logged in to vote

if you want a single class to have over multiple collections, you will have to change the name of the model to be used, otherwise mongoose will only create one of the models (or overwrite the older one, i dont know how it will react)

there are multiple ways to go about this:

  • create a model on multiple connections
  • change the name on each model

the easiest way would be to use a different name for each model, which in typegoose can be easily done by activating automaticName: true
and read through Typegoose's Name Generation to see how typegoose generates names

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by hasezoey
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@hasezoey
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #667 on February 07, 2022 08:59.