How use ObjectId search from Webhook in MongoDB

After Running this :


Output :

    "_id": {
      "$oid": "606aa80e929a618584d2758b"
    "id": "1",
    "tid": "1",
    "cid": "1",
    "title": "What is Time Complexity",
    "description": "So, the time complexity is the number of operations an algorithm performs to complete its task (considering that each operation takes the same amount of time).",
    "image": "",
    "author": "Hanry Kon"

I want same output based on ObjectId as Input
like :


Error after Running this Code:

> error: 
ReferenceError: 'ObjectId' is not defined
> trace: 
ReferenceError: 'ObjectId' is not defined
	at exports (function.js:28:43(28))
	at function_wrapper.js:3:34(21)
	at <eval>:11:8(17)
	at <eval>:2:15(7)

How can i do that By Using MongoDB Webhook

Did you import?

import { ObjectId } from "bson"

Thanks for Reply I was Able to solve my problem through this Article.

Solution : mcollection.find({"_id":new BSON.ObjectId(“606aa80e929a618584d2758b”)}).toArray();

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