Closed tbbooher closed 9 years ago
works . .
require 'mongo'
Mongo::Logger.logger.level = ::Logger::FATAL
entries = Mongo::Client.new('mongodb://user_name:password@127.0.0.1:27017/journal')["entries"]
puts "about to work #{entries.find.count} entries"
#entries = client["entries"]
dates = entries.find.map{|e| e[:entry_date]}
# puts dates
dates.each do |d|
if d.nil?
puts "nil value: #{d.inspect}"
else
new_date = d.gsub(/(\d+)\-(\d+)\-(\d+)/) {"#{$2}/#{$3}/#{$1}"}
puts "replacing #{entries.find({:entry_date => d}).first[:entry_date]} with #{new_date}" # .update_one("$set" => {:entry_date => new_date})
entries.find({:entry_date => d}).update_one("$set" => {:entry_date => new_date})
end
end
run this on the server:
https://gist.github.com/tbbooher/85a299b66123ffff032d