Skip to content

Instantly share code, notes, and snippets.

@stephentcannon
stephentcannon / gist:3396983
Created August 19, 2012 18:44
Meteor controller, action dynamic query
//this is used on a toggleChild function to add or remove mongo child relationships
//it works fine when for $pull but $addToSet doesn't ever seem to get sent to the server
if(window[Meteor.request.controller.capitalise()]["find"](query).count() == 0){
children[child_collection_name] = child;
modifiers['$addToSet'] = children;
modifiers['$set'] = { client_updated: ts };
} else if (window[Meteor.request.controller.capitalise()]["find"](query).count() == 1){
children[child_collection_name] = child;
@stephentcannon
stephentcannon / ftvi
Created May 26, 2012 10:01
findOne template view issue
//all of this is client side
//some of the concept is taken from
//http://stackoverflow.com/questions/10167464/meteor-rendering-template-with-a-document-from-a-collection/10167515#comment13990810_10167515
//collection setup
myCollection = new Meteor.Collection('myCollection');
//subscription is working
//the entire contents render perfectly in a template that shows all records
//it shows changes made server side or client side
@stephentcannon
stephentcannon / maxcstacksizeexceeded
Created May 18, 2012 11:12
Meteor collection maximum call stack size exceeded
var key = CryptoJS.AES.encrypt('test', 'password');
console.log('key: ' + key);
id = MyCollection.insert({
created: new Date(),
expires: expires,
key: key
}, function(error, result){
console.log('error: ' + error);
console.log('result: ' + error);
});