Simple realm function to search by ID?!

I have this function, which essentially does this:

    const database = context.services.get("mongodb-atlas").db("store");
    const skusColl = database.collection("skus");
    const skuId = new BSON.ObjectId(arg);
    const sku = database.collection.find({_id: skuId}).toArray();

calling the above in the console with: exports(‘611e5e564faf609f0d9aaa97’) throws the following error:

TypeError: Value is not an object: undefined

For anyone else running into this same problem, BSON.ObjectId(JSON.parse(JSON.stringify(arg))) solved this problem.

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.