Removing white spaces (leading and trailing) from string value
问题 I have imported a csv file in mongo using mongoimport and I want to remove leading and trailing white spaces from my string value. Is it possible directly in mongo to use a trim function for all collection or do I need to write a script for that? My collection contains elements such as: { "_id" : ObjectId("53857680f7b2eb611e843a32"), "category" : "Financial & Legal Services " } I want to apply trim function for all the collection so that "category" should not contain any leading and trailing