Skip to content
José Fresco edited this page Jun 29, 2015 · 17 revisions

Database scripts

Rename collection laws to topics

In a MongoDB shell please type the following:

db.laws.renameCollection('topics')

Rename field summary to body(not applicable)

summary field was renamed to body (#901). For backwards support you have to run in a MongoDB shell:

db.topics
  .find({})
  .snapshot()
  .forEach(function (e) {
    e.body = e.summary
    delete e.summary
    db.topics.save(e)
  })

db.comments
  .update({ context: 'summary' },
    { $set: { context: 'body' }}, 
    { multi: true })
Clone this wiki locally