def remove_blank_documents(db, coll): """ Removes documents from database which have empty 'text' fields """ results = collection(db, coll).find({"text": ""}, fields=["_id"]) for r in results: # print r collection(db, coll).remove({'_id': r['_id']})
def remove_blank_documents(db,coll): """ Removes documents from database which have empty 'text' fields """ results = collection(db,coll).find({"text":""}, fields=["_id"]) for r in results: # print r collection(db,coll).remove({'_id':r['_id']})
def process(self, msg): """ Write documents in the database and collection in batches of size self.batchsz """ # print msg coll = collection(msg.pop('database'), msg.pop('collection')) self.insertlist.append(msg) if len(self.insertlist) > self.batchsz: print "==> inserting...", coll.insert(self.insertlist) self.insertlist = []
def process(self, msg): """ Write documents in the database and collection in batches of size self.batchsz """ # print msg coll = collection(msg.pop('database'),msg.pop('collection')) self.insertlist.append(msg) if len(self.insertlist) > self.batchsz: print "==> inserting...", coll.insert(self.insertlist) self.insertlist = []