Skip to content

Instantly share code, notes, and snippets.

@anthonycrumley
Created January 18, 2016 20:25
Show Gist options
  • Save anthonycrumley/8af7653fca25c9b11823 to your computer and use it in GitHub Desktop.
Save anthonycrumley/8af7653fca25c9b11823 to your computer and use it in GitHub Desktop.
Add location to actions based on the network event.
require('mongo')
def client
@client ||= Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'network-dev')
end
def actions
client[:actions]
end
def network_events
client[:networkevents]
end
actions.find().each do |action|
if action[:networkEvent]
event = network_events.find(:_id => action[:networkEvent]).first
actions.update_one({ :_id => action[:_id] }, { "$set" => { :location => event[:location] }})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment