MongoDB update: Generate new field based on existing field, or update in place -


I am currently messing up for a while and no examples and explanations about the completion of this work is. / P>

I have a collection of documents, each document has a date / time zone. Ideally, I will have to prepare a new field for each document, where the value is based on the time from the date / time zone, which is connected with a constant factor.

Alternatively, updating the value in place will be enough.

I could not figure out how to reference the current document in a Mongo Shell update statement.

Is this stupid? Should I quit and write applications to eliminate this simple operation?

Thank you!

Sometimes by simply writing the question, you are brought to a solution, it's a bit, and of course Strange, but seems to work:

  db.actuals.find (). ForEach (function (d) {var dt = d.date; var ndt = new date (D.date) .setHours (dt.getHours () - 8); db.actuals.update ({_id: d._id}, {$ Set: {Local: New date (ndt)}}}}})  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -