title: encode url (or replace string / regex) in mongodb via node, mongoose
body: <p>I need to do some operations on one collection and at the end store the result in another collection. Will be doing this via aggregation. Platform is node, mongoose, mongodb.</p>
  
  <p>One of the required operations which I can't figure out is urlEncoding a particular field. The field can be constrained to only contain alphabets, numbers and spaces, so basically <strong>what I need to do is convert spaces to %20</strong></p>
  
  <p>Note that I need to do this while using node. I am pretty new in node, mongoose, mongodb, etc, so I'm not sure If I can run custom javascript code from node into mongoose or if that will be a good idea.</p>