MongoDB $trim

In MongoDB, the $trim aggregation pipeline operator removes whitespace from the beginning and end of a string. This includes the null character.

It can also remove any character specified. For example, you could use it to remove all hyphen characters (-) or periods (.) or all s characters, etc.

Read more

MongoDB $convert

In MongoDB, you can use the $convert aggregation pipeline operator to convert a value to a specified type.

You can convert any valid expression to a double, string, ObjectId, boolean, Date, integer, long, or decimal.

Read more

MongoDB Date() Method

In MongoDB, the Date() method returns a date either as a string or as a Date object.

  • When you call it as Date(), it returns the current date as a string in the mongo shell.
  • When you call it as new Date(), it returns the current date as a Date object.

You can also provide a specific date as an argument to new Date(), so that it uses that date.

Read more