Like I said in other question about date support, In the MongoDB documentation there is support for Extended JSON - Node driver should support this already. And so, a ObjectId could be represented by:
Interesting. This is quite helpful. We would probably have to make a breaking change in the node but still a good idea. Would you please make a feature request for this and upvote it?
@kimus How does your workaround work in the n8n node? I need this funtionality like, so bad. I can’t understand how it’s not included, it’s a super common uscase.
@RicardoE105 I ran accross the need for this feature this week so I created a PR that adds the option for it. It behaves the same way as the Date Fields. You pass a comma-delimited list of fields that you want converted to ObjectID before running the following operations: insert, update, findAndUpdate, findAndReplace. You think you can take a look and review?
Ok got it. Just wasn’t sure what your normal review process looks like. I tried to find info about in he docs but no luck, At least not in the CONTRIBUTING.md. I just know the github actions are pending approval. Is this review process described somewhere so I can read up?
The review process isn’t documented anywhere as while we would love to say we would review it within a week or 2 things can happen that would shift the priority so we tend to pop a message on the PR when we are about to start unless it is something really quick like fixing a typo.
Hey @kimus, I didn’t get notified of your response. Do you have an example of adding a related ObjectId to a document, like the original poster’s question?
@gravitoad I guess I should be more cleared on my reply.
I’ve used tthe $expr and $toObjectId to query the database and not for inserting or updating.
I did not tested or know how to use this in n8n MongoDB’s node. That seams to lack more advanced features.
Sorry about not clearing this out in first time.
Btw, In mongo you can convert string to ObjectId that by doing: