I'm using node.js and mongodb. After I make a query to mongodb, I'd like to format the date. I can modify strings, but not date objects. How come? Does it have something to do with my schema for the date set as Type date?
I know I can just create something new like docs.updatedFormated, but I'm mainly curious why I can't mutate the existing value since I thought in JavaScript you could pretty much mutate any type?
Post.findOne { slug: slug }, (err, docs) =>
console.log docs.updated # type date: -> MON MAY 25 2015 00:00:00 GMT-0400 (EDT)
console.log docs.title # type string: 'Example title'
docs.updated = 'I want a new string'
docs.title = 'Changed title'
console.log docs.updated # Same: -> MON MAY 25 2015 00:00:00 GMT-0400 (EDT)
console.log docs.title # Changed: -> 'Changed title'