Skip to content

Instantly share code, notes, and snippets.

@GarrettWeinberg
Last active April 4, 2022 18:03
Show Gist options
  • Save GarrettWeinberg/ceaa2fce43f9395228cd1094c297968e to your computer and use it in GitHub Desktop.
Save GarrettWeinberg/ceaa2fce43f9395228cd1094c297968e to your computer and use it in GitHub Desktop.
Mongo shell command to add new fields to collection
// shell
db.casestudies.find().forEach(function (data) {db.casestudies.update({_id: data._id}, {$set: {links: [],documents: {},}})});
// pretty
db.casestudies.find().forEach(function (data) {
db.casestudies.update({
_id: data._id
}, {
$set: {
links: [],
documents: {},
}
})
});
// import database
mongorestore --db rebelware_spark_staging --verbose /var/www/spark_alpha/server/rebelware_staging_BACKUP/rebelware_staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment