Skip to content

Instantly share code, notes, and snippets.

@james-gardner
Created July 8, 2018 19:00
Show Gist options
  • Save james-gardner/3b80a437ef1c21a20b5aba8aba889b52 to your computer and use it in GitHub Desktop.
Save james-gardner/3b80a437ef1c21a20b5aba8aba889b52 to your computer and use it in GitHub Desktop.
MongoDB Redact
db.request_log__v2_0.aggregate([{
"$redact": {
"$cond": [{
"$and": [{
"$eq": [{
"$year": "$created_at"
}, 2018]
}, {
"$eq": [{
"$month": "$created_at"
}, 3]
}]
}, "$$KEEP", "$$PRUNE"]
}
}, {
$out: "request_logs_2018_03"
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment