My meteor app interacts with a mongodb-backed node.js microservice. I want to use autoform on the meteor app without having to maintain two copies of the schemas.
The microservice schemas are mongoose but it was straighforward to write a translator for autoform's simple-schema.
Getting the translations into meteor has been the tough part.
First, I was going to use npm. That proved to be a problem because meteor/hacks can't use local (npm link'd) packages.
Then, I considered browserify. That was no good because mongoose isn't client-side compatible.
Finally, I decided to just serve up the translations with express.
The remaining issue is that I need to attach the schema with collection2 BEFORE autoform tries to render.
I put the HTTP request in a Meteor.method. How/Where do I call attachSchema() such that it occurs before rendering is attempted?
This is what I tried:
onBeforeAction: function () {
var self = this;
Meteor.call('fetchSchema', 'ModelName', function (err, schema) {
ModelName.attachSchema(new SimpleSchema(schema));
self.next();
});
}
I get this error:
Exception in delivering result of invoking 'fetchSchema': TypeError: object is not a function
How should I be going about this?