CopyPastor

Detecting plagiarism made easy.

Score: 0.806778609752655; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2023-11-16
by jQueeny

Original Post

Original - Posted on 2020-06-16
by Valijon



            
Present in both answers; Present only in the new answer; Present only in the old answer;

I'm not sure what your expected outcome is but you need to pass the number 7 as the first argument and the array to compare against as the second like so:
````javascript { $set: { offers: { $cond: [ { $in: [ 7, "$nl" ] }, { $concatArrays: [ "$offers", [] ] }, { $concatArrays: [ "$offers", [ { "name": "minimal", "prices": [] } ] ] } ] } } } ````
See [HERE](https://mongoplayground.net/p/9ENFyTFIilp) for a working example.
When you use `$expr`, the [operator expressions](https://docs.mongodb.com/manual/meta/aggregation-quick-reference/#operator-expressions) syntax changes a little:
{ $in: [ <expression>, <array expression> ] }
---
{ "$expr": { "$not": { "$and": [ { "$in": [ "$PrName", [ "pname" ] ] }, { "$in": [ "$AccountId", [ "34562", "88765", "87654", "12345" ] ] } ] } } }

        
Present in both answers; Present only in the new answer; Present only in the old answer;