mongodump command:
mongodump --host myhost.com --port 12345 --username myUsername --password PSWRD --out /opt/somepath --db myDb --collection my_collection --query "{ content_type_id: { \$not: { \$eq: db.my_type.findOne({slug: 'form_submissions'} )._id } } }" --verbose
Results in:
assertion: 16619 code FailedToParse: FailedToParse: Bad characters in value:
offset:33 of:{ content_type_id: { $not: { $eq: db.my_type.findOne({slug: 'form_submissions'} )._id } } }
That's not a valid query.
--query
must be a JSON document. Your error is in thinking that mongodump is something programmatic like the mongo shell that can evaluate thefindOne
and substitute the value into the query. This is not the case. You can find the_id
from the result of thefindOne
and put it in the mongodump--query
manually. Use extended JSON format for an ObjectId type, if that is the type of_id
.