vscode
vscode copied to clipboard
How to create a new property those value is ObjectId?
How to create a new property those value is ObjectId?
Question
Subject. I've tried doing: { $oid:
How are you inserting the document? If you're inserting it via a playground, you should be able to do something like:
db.getCollection("foo").insertOne({
_id: new ObjectId()
});
Alternatively, if you're editing an existing document, you should be able to use the ejson syntax and add a new field like:
{
...
"my-new-field": {
"$oid": "..."
}
}
We're aware that this is not ideal experience and is something we're planning to overhaul in the near future, but don't have concrete timelines to share that. And of course, if neither of these scenarios cover what you're trying to do, please add some repro steps and I'll try and take a look.