1

For some reason I can't eval this simple string in mongo, I think it's because the $exists parameter.

mongo database --eval "db.products.find({'csv': {'$exists': false}}, {'original.name': true, 'original.sku': true})"

1 Answer 1

4

Your quotes are the wrong way around. Use ' on the wrapping of the statement rather than ". Just the important parts:

--eval 'db.products.find({ "csv": { "$exists": false } })'
Sign up to request clarification or add additional context in comments.

2 Comments

Is curious that wihtout '$exists' original format works fine.
@JuanAntonio When you use double quotes for the eval string, bash interpolates $ variables, so it looks for a variable with name exists, which doesn't exist. To prevent the interpolation, you can use single quotes. When you don't have any $ sign in your eval string, either single or double quotes will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.