37 points · by zquestz · 14y ago · 31 comments
Sample, in your console type:
Messages.remove({})
or
Users.remove({})
If you have to implement a separate, server-side CRUD security check by hand, then I don't see why I would choose Meteor over say Rails or Express plus Backbone.
See http://nowjs.com for another implementation of the idea.
for(var i=0;i<20;i++) {Messages.insert({user: "testuser", text: "yo!", date: new Date()})};
Security stability and scalability are the hard parts.
Meteor.setInterval(function () { Users.remove({}); Messages.remove({}); }, 500);
One of the unfortunate things about Meteor at the moment is there aren't many open projects to learn from. For others trying to gain insights to best practices through this projects, here are some suggestions I may offer:
Users.find({last_seen: {$lt: (now - 60 * 1000)}}).forEach(function (user) { Users.remove(user._id); });
-> Users.remove({ last_seen: { $lt: (now - 60 * 1000) } });
and
Messages.find({date: {$gt: new Date()}}).forEach(function (message) { Messages.update(message._id, {$set: {date: new Date()}}); });
-> Messages.update({date: {$gt: new Date()}}, { $set: {+new Date() }})
Excellent work otherwise though. I'd love to see more open source projects released with Meteor if anything for others to learn from!
source: https://github.com/spicytuna/InstaChat
you can create rooms like this: http://instachat.meteor.com/room/HackerNews