Hello,i am using iron-cli to generate the structure of my app.I have created an app called crud and i have this code in my added.js template code
Template.Added.events({
'submit .crud': function(event){
event.preventDefault();
var name = event.target.name.value;
var type = event.target.type.value;
var number = event.target.number.value;
var post = {
input_name: name,
input_type: type,
input_number: number
};
console.log(post.input_name);
Meteor.call('insertData', post, function(error,result) {
if(!error){
console.log(result)
//console.log(result._id)
}
});
return false;
}
});
In my methods.js file,i have this code
'insertData': function(post){
Crud.insert({
name: post.input_name,
type: post.input_type,
number: post.input_number
});
}
This is my crud.js file
Crud = new Mongo.Collection('crud');
if (Meteor.isServer) {
Crud.allow({
insert: function (userId, doc) {
return true;
},
update: function (userId, doc, fieldNames, modifier) {
return true;
},
remove: function (userId, doc) {
return true;
}
});
}
Crud.attachSchema(new SimpleSchema({
name: {
type: String,
label: "Name",
max: 100
},
type: {
type: String,
label: "Type",
max: 100
},
number: {
type: String,
label: "Number",
allowedValues: ['100', '200', '300'],
}
}));
When i try to create a record,the inserting fails. How can i change my code to enable me insert data?.