加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

Meteor collection.insert回调问题

发布时间:2020-12-12 06:26:18 所属栏目:MsSql教程 来源:网络整理
导读:根据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
根据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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读