Hello !
I’m actually trying to make a parsing script in server side (Can’t say more about the script, but it doesn’t change anything)
Actually, I have a collection and a model like that :
Tags = new Mongo.Collection(‘tags’);
var Schemas = {};
Schemas.tags = new SimpleSchema({
tag: {
type: String,
unique: true
}
});
Tags.attachSchema(Schemas.tags)
Tags.allow({
insert: function(userId, tag) {
return true;
},
update: function(userId, tag, fields, modifier) {
return true;
},
remove: function(userId, tag) {
return true;
}
});
Then, in my script, I’m trying to insert a new tag inside the collections. Like that.
Console.log('Before insert');
Tags.insert({tag: item}, function(err, idTag){
if (err) {
var tagFind = Tags.findOne({tag : item});
def2.resolve(tagFind._id);
console.log("ALREADY FOUND TAG " + tagFind);
} else {
console.log("Creation of " + item + "in DB" + idTag);
def2.resolve(idTag);
}
});
console.log('After insert');
In the console, ‘Before the insert’ is display, and then, nothing more, and the program don’t go further…
And if a try to insert something in client side, everything works well.
I have to finish this app for tonight… And I’m stucked into this dumb problem.
Thanks for you help.