question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

findOneAndUpate options arrayFilters cannot use with $or (logical query operations)

See original GitHub issue
mongoose version: 5.13.8 
mongodb version: 3.6.17
node.js version: 12.13.3

I was using findOneAndUpdate() with arrayFilters in options. It didn’t work with logical query operator, like $or, $and.

{ _id: 'xxxxx' }, 
{
  '$set': {
    'identities.$[elem].workingStatus.workingStatus': 'xxx',
    'identities.$[elem].workingStatus.workingStatusUpdateTime': 'xxx'
  }
},
{
  "new": true,
  "arrayFilters": [
    {
      "$and": [
        {
          "$or": [
            {
              "elem.workingStatus.workingStatusManualTime": {
                "$exists": false
              }
            },
            {
              "elem.workingStatus.workingStatusManualTime": {
                "$lte": "xxx"       
              }
            }
          ]
        },
        {
          "elem.deleted": false
        }
      ]
    }
  ]
} 

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
IslandRhythmscommented, Sep 8, 2021

@Sulaiman90 please open a new issue a follow the format.

0reactions
Sulaiman90commented, Sep 8, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to use $or in array filters with updateOne - v6.0.5 #10696
Sulaiman90 mentioned this issue on Sep 8, 2021. findOneAndUpate options arrayFilters cannot use with $or (logical query operations) #10686.
Read more >
Update with array filter doesn't update anything mongo go driver
I should use : opt := options.FindOneAndUpdate().SetArrayFilters( options.ArrayFilters{ Filters: []interface{}{ bson.M{ "elem.name": bson.
Read more >
update — MongoDB Manual
The update methods provided by the MongoDB drivers use this command ... You cannot specify multiple collations for an operation. ... arrayFilters, array....
Read more >
Mongoose v6.8.2: API docs
[options.serverSelectionTimeoutMS] «Number» If useUnifiedTopology = true , the MongoDB driver will try to find a server to send any given operation to, ...
Read more >
options - Go Packages
Package options defines the optional configurations for the MongoDB Go Driver. ... Specifies a collation to use for string comparisons during the operation....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found