Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (50.2k points)

I'm a beginner in mongoosejs. I just don't understand why to trim. I'm designing my first schema today like a 'hello world'.

I want to learn more about it. I'm looking for an explanation for a beginner...

1 Answer

0 votes
by (107k points)
edited by

The strings that you have saved through the schema are accurately trimmed with the help of the 'trim' parameter. 

If you add trim to a field in your schema, then trying to save texts with spaces like "  qwerty", or "goat ", or " welcome", would now be stored as "qwerty", "goat" and "welcome" in Mongo - which means that the white spaces will be excluded from both sides of the text. The syntax for trim is : 

{ type: String, trim: true } 

Related questions

0 votes
1 answer
asked Jan 5, 2020 in Web Technology by ashely (50.2k points)
0 votes
1 answer
asked Feb 6, 2020 in Web Technology by ashely (50.2k points)
0 votes
1 answer
asked Jan 5, 2020 in Web Technology by ashely (50.2k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...