Meteor collection.insert回调问题

前端之家收集整理的这篇文章主要介绍了Meteor collection.insert回调问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
根据Meteor文档….

collection.insert(doc,[callback])

callback Function

Optional. If present,called with an error object as the first argument and the _id as the second.

……然后……

On the server,if you don’t provide a callback,then insert blocks until the database acknowledges the write,or throws an exception if something went wrong. If you do provide a callback,insert returns immediately. Once the insert completes (or fails),the callback is called with error and result arguments,same as for methods.

它是什么,错误和_id或错误和结果?我确实有Meteor.methods正在触发错误的回调,结果可用于范围.

我只是无法使回调在collection.insert(doc,[callback])上正常工作

无论哪种方式,我都无法让我的回调注册任何东西?

function insertPost(args) {
  this.unblock;
  if(args) { 
    post_text = args.text.slice(0,140);
    var ts = Date.now();  
    Posts.insert({
      post: post_text,created: ts
    },function(error,_id){
      // or try function(error,result) and still get nothing 
      // console.log('result: ' + result);
      console.log('error: ' + error);
      console.log('_id: ' + _id); //this._id doesn't work either
    });

  }
  return;
}

我究竟做错了什么?我从凌晨2点开始编码…下午6点我的时区……我很模糊,所以我可能(可能)遗漏了一些非常明显的东西.

干杯
吊杆

解决方法

这是一个错误,在下一个版本中已修复.现在,如果您提供要插入的回调,则将使用error和result参数调用它,其中result是新文档的ID,如果出现错误则为null.

猜你在找的MsSQL相关文章