Skip to content

Instantly share code, notes, and snippets.

@Almad
Created August 9, 2012 12:39
Show Gist options
  • Save Almad/3303863 to your computer and use it in GitHub Desktop.
Save Almad/3303863 to your computer and use it in GitHub Desktop.
cmd fix approach
async = require 'async'
datamodel= require '../lib/datamodel'
mongoose = require 'mongoose'
Traffic = mongoose.model 'Traffic'
mongoose.connection.once 'open', ->
Traffic.find {}, (err, traffic) ->
async.forEach traffic, (hit, done) ->
hit.fixSomething
hit.save done
, (err) ->
console.error "#{traffic?.length} traffic objects updated."
datamodel.disconnect()
if err then throw err
datamodel.connect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment