Flow Router doesn't work with ObjectID. Any fix?

后端 未结 1 810
逝去的感伤
逝去的感伤 2021-01-20 21:14

I\'m trying to build routes in my Meteor app. Routing works perfectly fine but getting information from db with route path just doesn\'t work. I create my page specific rout

1条回答
  •  太阳男子
    2021-01-20 21:42

    MongoDB used ObjectIds as _ids by default and Meteor explicitly sets GUID strings by default.

    Perhaps you inserted using a meteor shell session in the past and now used a mongo shell/GUI or a meteor mongo prompt to do so, which resulted in ObjectIds being created.

    If this happens in a development environment, you could generate the data again.

    Otherwise, you could try to generate new _ids for your data using Meteor.uuid().

    If you want to use ObjectId as the default for a certain collection, you can specify the idGeneration option to its constructor as 'MONGO'.

    If you have the string content of an ObjectId and want to convert it, you can issue

    let _id = new Mongo.ObjectID(my23HexCharString);
    

    0 讨论(0)
提交回复
热议问题