Skip to content
Sacha Lifszyc edited this page Jun 10, 2014 · 3 revisions

Important: if you're migrating from a version prior to 0.4.0 you should read this before proceeding.

law.$comment.score

A new field named score has been added with the sorting comments feature at this release. This allows to sort comments according to their score, being calculated as follows: comment.score = comment.upvotes - comment.downvotes (minus).

In order to sort your comments you need to run the following command at your MongoDB shell:

db.comments.find().forEach(function (c) {
  var positive = c.votes.filter( function (v) {
    return v.value == 'positive';
  }).length;
  var negative = c.votes.filter( function (v) {
    return v.value == 'negative';
  }).length;
  var score = positive - negative;
  db.comments.update( { _id: c._id }, { $set: { score: score } } );
});

After this, the score will be set to corresponding number for each comment. And subsequent upvotes and downvotes will modify the comment.score field to reflect this new score.

law.$clauses.clauseName

clauseId has been deprecated as an id is not always required, as well as the prefixed word Clause: for displaying each clause on the law's article.

In order to rename each clauseId to clauseName in your database, run the following command at your MongoDB shell:

db.laws.find().forEach(function (law) {
  law.clauses.forEach(function(c) {
  	c.clauseName = c.clauseId;
  	delete c.clauseId;
  });
  db.laws.update( { _id: law._id }, law);
});