Skip to content

Instantly share code, notes, and snippets.

@syuilo
Last active January 11, 2016 18:01
Show Gist options
  • Save syuilo/829829b70eec3316f44b to your computer and use it in GitHub Desktop.
Save syuilo/829829b70eec3316f44b to your computer and use it in GitHub Desktop.
db.Posts.update({}, {$rename:{"photos":"files"}}, false, true);
db.Posts.find({}, {
'_v': 0,
'repostsCount': 0,
'repliesCount': 0,
'likesCount': 0,
'isDeleted': 0,
'channel': 0,
'app': 0,
'hashtags': 0,
'post': 0,
'user': 0,
'createdAt': 0,
'text': 0
}).forEach(function(post) {
print(post.cursor);
if (post.type != 'repost' && post.inReplyToPost == null) {
db.Posts.update({_id:post._id}, {
$set : {"type": "status"},
$unset: {"inReplyToPost": 1}
}, false, false);
if (!post.hasOwnProperty('files')) {
db.Posts.update({_id:post._id}, {
$set : {"files": null}
}, false, false);
}
} else if (post.type != 'repost' && post.inReplyToPost != null) {
db.Posts.update({_id:post._id}, {
$set : {"type": "reply"}
}, false, false);
if (!post.hasOwnProperty('files')) {
db.Posts.update({_id:post._id}, {
$set : {"files": null}
}, false, false);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment