且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

了解新的mongo id并将其与iron-router一起使用

更新时间:2023-12-03 14:45:58

您需要更改pathFor 'post'以传递ObjectId 52e16453431fc2fba4b6d6a8而不是ObjectId('52e16453431fc2fba4b6d6a8')

You need to change the pathFor 'post' to pass the hex representation of the ObjectId 52e16453431fc2fba4b6d6a8 instead of ObjectId('52e16453431fc2fba4b6d6a8')

尝试这样的方式pathFor 'post' _id=this._id.toHexString

一旦您传递了十六进制字符串,就可以在路由器中使用它

Once you are passing the hex string, you can use this in your router

return Posts.findOne({ _id: new Meteor.Collection.ObjectID(this.params._id)});