Collection findOne not working?

This is my code:

  if (subTasks.ready()) {
    for (let _id in Meteor.user().profile.saved.ids) {
      let found = TasksDB.findOne({_id});
    }

Thing is, “found” always returns undefined for some reason. I can use ‘findOne’ in other components, and the code is the same; I wait til the database is ready, then I query.

I can use TasksDB.find({}).fetch(); and it will show me everything in the database, but I can’t seem to use findOne. Any reason why?

I also tried TasksDB.findOne({_id: new Meteor.}); but all I get is this error:

Invalid hexadecimal string for creating an ObjectID

So it would seem that I’m not using MeteorIDs in my database, but rather strings as IDs.

Help will be appreciated, thanks!

I would start by verifying that _id variables in the for loop contain a string identifier which exists in your TasksDB collection. Try putting a console.log(_id); in there and check it.

Thanks, it seems like the _id isn’t even a proper id, but rather an int of the index of the array. Guess now I know why it isn’t working