Skip to content

Instantly share code, notes, and snippets.

@aaronthorp
aaronthorp / mongo-each.js
Last active January 2, 2016 08:49
MongoDB For-Each Loop Script
db.organisations.find({}).forEach(function(doc) {
doc.users = [
{_id: doc.user}
];
db.organisations.save(doc);
});
@aaronthorp
aaronthorp / controller.js
Last active January 2, 2016 05:09
Iron-Router - Login check for each route
RouteController.extend({
before: function() {
if (_.isNull(Meteor.user()) && Router.current().route.name != 'loginPage') {
console.log("Redirect to login!");
this.stop();
Router.go('loginPage');
}
}
});