appsmith: [Bug]-[2960]:MongoDB update query is not accepting valid value (an array) in update field

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

This query is valid for MongoDB 4.2+

db.getCollection('user').updateOne(
    {"_id":"1"    },
    [{"$set":{"newField":"$name"}}]
)

And in order to work correctly the $set part needs to be in an array. But when we try to do something similar via Appsmith, It throws an error: Screenshot 2022-02-24 145332

Hint

https://github.com/appsmithorg/appsmith/pull/12241#discussion_r844997566

Steps To Reproduce

Like the Image above:

  1. Create an update query in a MongoDB datasource
  2. Enter an update statement in array form like this one [{"$set":{"testField":"$status"}}]
  3. It fails when you run the query with this error: Execution failed with status 5005 No valid mongo command found. Please select a command from the "Command" dropdown and try again

Environment

Production

Version

Cloud

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (14 by maintainers)

Most upvoted comments

@rlnorthcutt, for Hacktoberfest considerations.

@amogh2019 we will take care of this internally. I am hoping this issue remaining open should not be a problem wrt to the Hacktoberfest contributions.

@amogh2019 assigned the issue to you.

@Nikhil-Nandagopal I think this is an easy and low-effort issue. @devnamrits can work on this and I will help him in case of any problem.