bulk.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:aiomongo 作者: ZeoAlliance 项目源码 文件源码
def execute(self, write_concern: dict) -> dict:
        """Execute operations.
        """
        if not self.ops:
            raise InvalidOperation('No operations to execute')
        if self.executed:
            raise InvalidOperation('Bulk operations can '
                                   'only be executed once.')

        self.executed = True
        write_concern = (WriteConcern(**write_concern) if
                         write_concern else self.collection.write_concern)

        if self.ordered:
            generator = self.gen_ordered()
        else:
            generator = self.gen_unordered()

        connection = await self.collection.database.client.get_connection()

        if connection.max_wire_version < 5 and self.uses_collation:
            raise ConfigurationError(
                'Must be connected to MongoDB 3.4+ to use a collation.')

        if not write_concern.acknowledged:
            if self.uses_collation:
                raise ConfigurationError(
                    'Collation is unsupported for unacknowledged writes.')
            await self.execute_no_results(connection, generator)
        else:
            return await self.execute_command(connection, generator, write_concern)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号