Skip to content

Instantly share code, notes, and snippets.

var debug = function(str) {
console.log('counter-cache: ' + str);
};
Meteor.Collection.prototype.maintainCountOf = function(collection, field, counterField) {
var self = this;
// what is Meteor.users an instanceof ?
// if (! (collection instanceof Meteor.Collection))
// throw new Error("Expected first parameter to be a Meteor Collection");
@dburles
dburles / gist:9302416
Created March 2, 2014 05:36
pub/sub pattern
//
// publish list of books (and authors)
//
Books.mainListCursor = function() {
return Books.find({}, { sort: { createdAt: -1 }, limit: 10 });
};
if (Meteor.isServer) {
Meteor.publish('books', function() {
<form id="filter">
{{#with profileFilter}}
<input type="text" name="nameFilter" value="{{search}}" placeholder="Filter users" />
<fieldset class="radio-fieldset">
<label>
<input type="radio" name="typeFilter" value="" {{typeSelected ''}} />
Show all
</label>
## Meteor Patterns ##
----------
# Simple Search
- Avoid duplicating the same query code on the client and server.
- Provide some simple search results.
> common/utils.js
## Meteor Patterns ##
----------
# 1. Simple Search
- Avoid duplicating the same query code on the client and server.
- Provide some simple search results.
> common/utils.js
## Meteor Patterns ##
----------
# 1. Simple Search
- Avoid duplicating the same query code on the client and server.
- Provide some simple search results.
> common/utils.js
Template.layout.events({
'click .terms-modal': function() {
Session.set('showTermsModal', true);
}
});
Template.layout.helpers({
termsModalOpen: function() {
return !!Session.get('showTermsModal');
}
UI.registerHelper('sourceCode', function() {
return Template.sourceCode;
});
<template name="sourceCode">
<pre><code data-language="html">
{{> UI.contentBlock}}
</code></pre>
</template>
Template.facetFilterItem.helpers({
isChecked: function(name, _id) {
return _.indexOf(Facet.get(name), _id) !== -1;
}
});
Facet = (function() {
var set = function(name, value) {
var current = Router.current();
var params = {};
Router.query = (function(router) {
var current = function() {
return router.current();
};
var currentParams = function() {
return current().params;
};
var currentQueryParams = function() {