I’m using validated-method to created a insert method but it crash to run meteor with the next message:
W20160221-11:32:45.394(1)? (STDERR) /home/abayta/Desktop/webstormWorkspace/nutrideta/.meteor/local/build/programs/server/app/lib/collections/recipes.js:87
W20160221-11:32:45.394(1)? (STDERR) run() {
W20160221-11:32:45.394(1)? (STDERR) ^
W20160221-11:32:45.396(1)? (STDERR) SyntaxError: Unexpected token (
W20160221-11:32:45.396(1)? (STDERR) at /home/abayta/Desktop/webstormWorkspace/nutrideta/.meteor/local/build/programs/server/boot.js:241:30
W20160221-11:32:45.396(1)? (STDERR) at Array.forEach (native)
W20160221-11:32:45.396(1)? (STDERR) at Function..each..forEach (/home/abayta/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20160221-11:32:45.396(1)? (STDERR) at /home/abayta/Desktop/webstormWorkspace/nutrideta/.meteor/local/build/programs/server/boot.js:137:5
The code is:
Recipes = new Mongo.Collection(‘recipes’);
recipeSchema = new SimpleSchema({
name: {
type: String,
label: “Name”
},
description: {
type: String,
label: “Description”
},
preparation: {
type: String,
label: “Preparation”
},
preparationTime: {
type: String,
label: “Preparation Time”
},
energy: {
type: Number,
label: “Energy”
},
fats: {
type: Number,
label: “Fats”
},
carbohydrates: {
type: Number,
label: “Carbohydrates”
},
protein: {
type: Number,
label: “Protein”
},
author: {
type: String,
label: “Author”,
autoValue: function() {
return this.userId;
},
autoform: {
type: “hidden”
}
},
createdAt: {
type: Date,
label: “Created At”,
autoValue: function() {
return new Date();
},
autoform: {
type: “hidden”
}
}
});
Recipes.attachSchema(recipeSchema);
Recipes.methods = {};
Recipes.methods.newRecipe = new ValidatedMethod({
name: ‘Recipes.methods.newRecipe’,
validate: recipeSchema.validator(),
run(){
}
});
It crash too with the example method of mdg:validated-method from github.
What I am doing wrong? I am going mad.