Skip to content

Instantly share code, notes, and snippets.

Created March 8, 2013 03:11
Show Gist options
  • Select an option

  • Save anonymous/5113947 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/5113947 to your computer and use it in GitHub Desktop.
Simple meteor pub/sub example.
["posts ready..."]
> Meteor.call('addPost', {header: 'testheader', content: 'testcontent'}, function(err, res) {console.debug(err, res)});
undefined
undefined Object {_str: "9f1cf3e2909abf6a69630e6e"}
//now i expect a ["posts ready..."]?
if(Meteor.isClient) {
var Posts = new Meteor.Collection('posts', {
idGeneration: 'MONGO'
});
Meteor.autorun(function() {
Meteor.subscribe('posts', function() {
console.debug('posts ready...');
});
});
}
preserve-inputs
accounts-base
accounts-password
bootstrap
ejson
handlebars
jquery
less
showdown
underscore
$>NODE_OPTIONS="--debug=5858" MONGO_URL="mongodb://127.0.0.1/database" meteor --settings server/settings.json
[[[[[ ~/example ]]]]]
Running on: http://localhost:3000/
debugger listening on port 5858
if(Meteor.isServer) {
var Posts = new Meteor.Collection('posts', {
idGeneration: 'MONGO'
});
Meteor.publish('posts', function() {
return Posts.find();
});
Meteor.methods({
'addPost': function(data) {
return Posts.insert({
header: data.header,
content: data.content
}, function(err) {
if(err) {
throw new Meteor.Error(500, 'internal server error!');
}
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment