我不确定为什么我在Collection.insert
之后没有收到来自服务器的回调。我一直指的是this stack,但我似乎无法弄清楚如何获得成功或错误插入的回调。
Server.js
Meteor.startup(function () {
// Using matb33:collection-hooks, this will record a timestamp before
// each resonance is created
Resonance.before.insert(function(userId, doc){
doc.createdAt = new Date();
})
if (Resonance.find().count() === 0) {
for (var i = 0; i < resonance.length; i++)
Resonance.insert({ email: resonance[i].email }, function(error, result) {
if (error) console.log ('there was an error!');
if (result) console.log ('Success!!!');
});
}
});