2

I am triying remove field in a big document, therefore I would like to do something:

collection.update({'_id' => @id},  {"$unset" => {'herField'})

But it is not possible. I don't want to rewrite entire document, any idea?

EDIT: I am using https://github.com/mongodb/mongo-ruby-driver

ie8888
  • 171
  • 1
  • 10

1 Answers1

2

Your syntax looks slightly incorrect. As per docs:

collection.update( { _id: @id }, { $unset: { herField: true } }, { multi: true });

Need the 'multi' option if you want to update multiple documents. E.g. from all records on this collection.

http://docs.mongodb.org/manual/reference/operator/unset/#op._S_unset

mu is too short
  • 426,620
  • 70
  • 833
  • 800
mbaird
  • 4,059
  • 2
  • 16
  • 14