Home > Net >  Mongoose - Best approach for storing Set in schema
Mongoose - Best approach for storing Set in schema

Time:12-22

My model contains Set, and I would like to model my schema in the most elegant way to have working serialization and deserialization. What should I do? I know there are schema types for Array, Map, Array of Arrays, but what to do with Set and when I should transform my Set because it won't be possible to store Set in DB, I assume...

CodePudding user response:

Use Array type could be fine, and cooperate with $addToSet, $pull and other array operators

CodePudding user response:

But is there a chance to have in my model Set and Array in a schema? If not how should I map that Set to Array and in which moment.

Thanks!

  • Related