根据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点我的时区……我很模糊,所以我可能(可能)遗漏了一些非常明显的东西.
干杯
吊杆