我想在meteor.collection.insert的回调中获取新插入的文档的id。
我插入文档如下:
Meteor.call('createDoc', {
key1: value1,
key2: value2
})
createDoc 函数如下所示:
Meteor.methods createDoc: (options) ->
incidents.insert
key1: options.value1
key2: options.value2
, callback(error, result)
callback = (error,result) ->
console.log result
文档说:
callback Function
Optional. If present, called with an error object as the first argument and,
if no error,the _id as the second.
所以我希望结果返回新的 id,但我得到一个参考错误,说错误和结果没有定义。我在这里做错了什么?非常感谢任何帮助。