I use transform to have a reference between Stores and StoreTypes.
Stores = new Mongo.Collection('stores', {
transform: function(doc) {
doc.storetypesObj = StoreTypes.find({
_id: { $in: doc.types }
});
return doc;
}
});
and in my StoreTypes collection I use:
StoreTypes = new Mongo.Collection('storetypes', {
transform: function(doc) {
doc.storesObj = Stores.find({
types: { $in: [ doc._id ] }
});
return doc;
}
});
However this transform makes it impossible to update my Store using an update form like this:
{{> quickForm collection="Stores" id=updateStoreId type="update" doc=this}}
This will following exception:
Exception from Tracker recompute function:
meteor.js:880 RangeError: Maximum call stack size exceeded
at Object.EJSON.clone (ejson.js:490)
at ejson.js:529
at Function._.each._.forEach (underscore.js:157)
at Object.EJSON.clone (ejson.js:528)
at ejson.js:529
at Function._.each._.forEach (underscore.js:157)
at Object.EJSON.clone (ejson.js:528)
at ejson.js:529
at Function._.each._.forEach (underscore.js:157)
at Object.EJSON.clone (ejson.js:528)
If I remove the transform I am no longer able to display the properties of my referenced StoreTypes, but am able to update, so it definitely has to do with the transform function.
Insert forms work. Only Update forms a problem.
(If anyone knows a workaround for this those are definitely welcome too. )