微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.

原文地址:https://www.jb51.cc/mssql/79108.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐