Permalink
Browse files

Made mongodb-remove-field.py more efficient

  • Loading branch information...
turian committed May 17, 2011
1 parent 99a73b5 commit 45e922ab07af17c06555d61c634e3ed89d50424a
Showing with 5 additions and 4 deletions.
  1. +5 −4 mongodb-remove-field.py
View
@@ -20,7 +20,8 @@
assert options.field is not None
collection = common.mongodb.collection(DATABASE=options.database, name=options.collection, PORT=options.port, HOSTNAME=options.hostname)
-for doc in common.mongodb.findall(collection, matchfn=lambda doc: options.field in doc, matchfn_description="has field %s" % options.field):
- print "FAKING IT, not actually removing %s: %s" % (options.field, repr(doc[options.field]))
-# del doc[options.field]
-# collection.save(doc)
+for doc in common.mongodb.findall_with_field(collection, field=options.field):
+# print "FAKING IT, not actually removing %s: %s" % (options.field, repr(doc[options.field]))
+ print doc["_id"]
+ del doc[options.field]
+ collection.save(doc)

0 comments on commit 45e922a

Please sign in to comment.