Sign In Register

How can we help you today?

Start a new topic

How to insert ObjectId into a document from NoSQL explorer?


I am trying to insert a document using NoSQL explorer which would contain an ObjectId, but I get the following error:

"Error parsing JSON. Please use valid JSON, including double-quotes on object keys."


my document looks like this:

        "_id": new ObjectId("597f73ae46e0fb0001b865f3"),
        "Name": "Baz",
        "Type": "Bing"
        "_id":new  ObjectId( "597f73ae46e0fb0001b865f4"),
        "Name": "Foo",
        "Type": "Bar"

I have tried removing the 'new' keyword and a few other things, to no avail.

How can I specify I want an ObjectID as the type so that it doesn't create a string, using the NoSQL explorer?

Thanks for any help!

1 Comment

You can't use javascript, so "new ObjectId(...)" won't work. That would only work in the console, which we don't have access to.

But you can use '$oid' like so:

{ "_id" : { "$oid" : "597f73ae46e0fb0001b865f4" } }

Login to post a comment