The link is http://mongoosejs.com/docs/api.html#schema_string_SchemaString-trim
I'm beginner in mongoosejs. I just don't get it...
I saw this question How to update mongoose default string schema property trim? but don't understand why trim. Im creating my first schema today like a 'hello world'.
I saw this to https://stackoverflow.com/tags/trim/info ... but when i need to use it, i want to learn more about it. Im looking for an explanation for a beginner...
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.