@tornado.gen.coroutine
    def bulk(self):
        params = self.params.getParams()
        data = params['bulk']
        try:
            bulk = self.collection.initialize_ordered_bulk_op()
            data = params['bulk']
            if 'insert' in data:
                for obj in data['insert']:
                    obj['created'] = datetime.datetime.utcnow()
                    obj['_id'] = ObjectId()
                    bulk.insert(obj)
            result = yield bulk.execute()
        except BulkWriteError as e:
            self.setResponseDictErrors(e)

            '''
            bulk = self.collection.initialize_ordered_bulk_op()
            # Remove all documents from the previous example.
            bulk.find({}).remove()
            for i in range(10000):
                bulk.insert({'_id': i})
            #bulk.insert({'_id': 2})
            #bulk.insert({'_id': 3})
            bulk.find({'_id': 1}).update({'$set': {'foo': 'bar'}})
            bulk.find({'_id': 4}).upsert().update({'$inc': {'j': 1}})
            bulk.find({'j': 1}).replace_one({'j': 2})
            result = yield bulk.execute()
            '''
dataset/ETHPy150Open tgonzales/mingus/mingus/resources.py/ResourceModel.bulk/original