What's the meaning of 'trim' when use in mongoose?
It's basically there to ensure the strings you save through the schema are properly trimmed. If you add { type: String, trim: true }
to a field in your schema, then trying to save strings like " hello"
, or "hello "
, or " hello "
, would end up being saved as "hello"
in Mongo - i.e. white spaces will be removed from both sides of the string.