0

Something strange in this neighbourhood. Calling DBA's and ! GB

db.getCollection('contacts').update({}, {$set: {"source": "domain.txt"}},false,true);

It failed with:

admin> db.getCollection('contacts').update({}, {$set: {"source": "domain.txt"}},false,true);
[2020-09-29 23:24:32] java.lang.IllegalArgumentException: options should be an object: false
[2020-09-29 23:24:32] options should be an object: false

Also, table feels a little corrupted. No longer displays the amount of records.

Based on answers from https://stackoverflow.com/questions/7714216/add-new-field-to-every-document-in-a-mongodb-collection

  • Check out the doc for db.collection.update, I'm not sure what you intended with those booleans, but that's not the right syntax. – Joe Sep 30 at 10:27
  • Also, update operation in MongoDB has various methods, updateOne, updateMany, etc. See Update Documents. – prasad_ Oct 1 at 3:56
  • @Joe it is. for upsert and multi – Ben Fourie Oct 1 at 7:01
1

Turns out mongo cli client needs to be on version 4.4 I had version 3

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.