Skip to content

Conversation

@garnaizd
Copy link

@garnaizd garnaizd commented Feb 9, 2018

Corrected expresion $$REMOVE to $REMOVE.

Error mesage is:

E QUERY [thread1] Error: command failed: {
"ok" : 0,
"errmsg" : "Use of undefined variable: REMOVE",
"code" : 17276,
"codeName" : "Location17276"
}

when executing:

db.prueba.aggregate( [ { $project: { title: 1, "author.first": 1, "author.last" : 1, "author.middle": { $cond: { if: { $eq: [ "", "$author.middle" ] }, then: "$$REMOVE", else: "$author.middle" } } } } ] )


This change is Reviewable

@garnaizd garnaizd changed the title Corrected expresion Corrected expresion $$REMOVE Feb 9, 2018
@steveren
Copy link
Contributor

steveren commented Feb 9, 2018

This code example can be found here: https://docs.mongodb.com/manual/reference/operator/aggregation/project/#conditionally-exclude-fields

I tested the complete example with MongoDB v3.6 and it executed correctly.

@garnaizd can you confirm your server and shell versions?

@garnaizd
Copy link
Author

garnaizd commented Feb 9, 2018

Maybe the error is for the version, because my version is MongoDB shell version v3.4.10

@steveren

@steveren
Copy link
Contributor

steveren commented Feb 9, 2018

That's correct. The REMOVE aggregation variable is new in version 3.6. https://docs.mongodb.com/manual/reference/aggregation-variables/#variable.REMOVE

@garnaizd

@garnaizd
Copy link
Author

garnaizd commented Feb 9, 2018

That's right. thank you @steveren.
Close this pull request.

@garnaizd garnaizd closed this Feb 9, 2018
jeff-allen-mongo pushed a commit that referenced this pull request Jun 7, 2023
* DOCSP-29684 Add Bitwise Operators to Aggregation Page

* spacing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants