Skip to content

Instantly share code, notes, and snippets.

@yeputons
Created March 23, 2014 19:44
Show Gist options
  • Save yeputons/9728755 to your computer and use it in GitHub Desktop.
Save yeputons/9728755 to your computer and use it in GitHub Desktop.
<head>
<title>oplog-test-3</title>
</head>
<body>
{{> serverFacts}}
{{> items}}
</body>
<template name="items">
<h3>Items</h3>
<ol>
{{#each items}}
<li>{{val}}</li>
{{/each}}
</ul>
</template>
Items = new Meteor.Collection('items');
if (Meteor.isClient) {
Template.items.helpers({
items: function() { return Items.find(); }
});
Meteor.startup(function() {
Meteor.subscribe('items');
});
}
if (Meteor.isServer) {
if (Items.find().count() == 0) {
for (var i = 0; i < 10; i++)
Items.insert({val: i});
}
Meteor.publish('items', function() {
return Items.find({}, {limit: 2,
//sort: {val: 1}
});
});
Facts.setUserIdFilter(function (userId) {
return true;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment