Automatically parse some fields to string on mongoose?
Mongoose allows a set
property, in your Schema, that will be used to alter the value before insertion.
You could use this set
property to "stringify" your values.
{
name: { type: String, required: true },
value: { type: String, required: true, set: (val) => val.toString()},
other: {
otherValue: { type: String, required: true, set: (val) => val.toString() },
}
}