Skip to content

Instantly share code, notes, and snippets.

@oeo
Created October 8, 2021 18:42
Show Gist options
  • Save oeo/179a28905befff5201ff23263ad7c373 to your computer and use it in GitHub Desktop.
Save oeo/179a28905befff5201ff23263ad7c373 to your computer and use it in GitHub Desktop.
process.env.SILENCE = 1
_ = require('wegweg')({
globals: on
shelljs: on
})
log = (x...) -> try console.log x...
_help = ->
log """
Usage ./ ENV=dk-prod --out <filename>
"""
exit 0
if _.arg('help') then _help()
if !_.arg('out')
throw new Error '--out required'
exit 1
##############################
require '../../../dev'
require '../../core/globals'
##############################
fields = [
'event'
'ip'
'ctime'
'LANDING_PAGE_ROUTE'
]
if _.exists(_.arg('out'))
try rm _.arg('out')
command = """
mongoexport --uri "#{process.env.MONGODB_URI}" \
-vvvv \
--type json \
--collection events \
--fields "#{fields.join(',')}" \
--forceTableScan \
--out #{_.arg('out')}
"""
log command
exec command
log 'Finished'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment