Find ObjectId in Meteor after Bulk Write

let theContact;
                                    if (theContactMatch.contact_id.length === 24) {
                                        console.log("[RTMS_Distributions] theContactMatch.contact_id is 24 characters long");
                                        theContact = await Contacts.findOneAsync({ _id: theContactMatch.contact_id._str });
                                    } else {
                                        console.log("[RTMS_Distributions] theContactMatch.contact_id is not 24 characters long");
                                        theContact = await Contacts.findOneAsync({ _id: theContactMatch.contact_id });
                                    }

Iā€™m losing my marbles man, I had to do a bulk import cuz I allow CSV uploads which contain thousands of records.

Now their _id is a freaking object in mongo.

How the hell do I get a record by an _id that is AN OBJECT

Generate your own _id during insert

1 Like

Did you use the underlying raw collection or the Mongo Collection API for the bulk insert?

I had incorrectly done this before, reviewed my code, used the random package and yep, works PERFECTLY. Thanks!