I want to update data in mongodb. update key is _id but is not objectid

i want to update data in mongodb. update key is _id but is not objectid.
when i run it , it show error “ERROR: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer”

Hi @suphakon_prabtook :wave: Welcome to the community :tada:

Can you share your workflow with us / any relevant JSON (of course, redact anything sensitive) and let us know the following:

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

n8n version : 1.8.2
Database : postgreSQL
n8n EXECUTIONS_MODE :queue
** EXECUTIONS_PROCESS : default
** Running on : docker destop

Hi @suphakon_prabtook :wave:

Looks like there’s a workaround here: MongoDB update field value as ObjectId - #6 by kimus

So a workaround would look something like { "$expr": { "$eq": ["$_id", { "$toObjectId": "<object-id>" }] } } - can you give that a shot? :bowing_man:

“_id” in my mongodb is string not object id
i want to update “other.is_best_deal”

Hey @suphakon_prabtook,

Which node is throwing the error message? Are you also able to share a rough structure and some sample data for your collection so we can set up a quick test?

1 Like

In update box error.
ERROR: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer

I want to update all is_best_deal to True.

{
"_id":"A1234",
"other":{
  "is_best_deal":false
}
}

Hi @suphakon_prabtook :wave: Just tested this - unfortunately this does indeed look like a bug, and I’m afraid I wouldn’t know of a workaround for this one. I’ve let our engineering team know about this, and will update the thread as soon as I have any further information :bowing_man:

2 Likes